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

16 Replies, 2058 Views

For json dumps without newlines, you’re almost there! Just make sure you’re not using any other formatting tools or libraries that might interfere.

Here’s a quick example:
```python
import json
data = {"example": "data"}
print(json.dumps(data, indent=None, separators=(',', ':')))
```

If you’re still stuck, maybe try [jsoneditoronline.org](https://jsoneditoronline.org) to manually check your JSON output.

Messages In This Thread



Users browsing this thread: 1 Guest(s)