How to Use json.dumps Without Newlines in a Dictionary for Compact Output?

22 Replies, 2093 Views

Hey, I ran into the same issue a while back! Your solution with `json.dumps(my_dict, separators=(',', ':'))` is spot on. That’s the cleanest way to get json dumps without newlines in a dictionary.

If you’re looking for a tool to test JSON outputs quickly, check out [jsonlint.com](https://jsonlint.com). It’s super handy for validating and formatting JSON, though you’ll need to manually remove spaces if you want it compact.

Messages In This Thread



Users browsing this thread: 1 Guest(s)