Still pasting JSON into websites to read it? Python gives you a cleaner, offline way in one line.
📦 The Built-in Way — No Extra Installs
Python ships with a powerful toolset for handling JSON.
Here's how to pretty-print JSON instantly:
import json
with open("data.json") as f:
data = json.load(f)
print(json.dumps(data, indent=4))
✅ Indented
✅ Readable
✅ Offline & fast
🔀 Bonus: From String Instead of File
json_str = '{"name":"name","skills":["skill1","skill2"]}'
print(json.dumps(json.loads(json_str), indent=2))
🧠 Real Uses
- Debug API responses
- View config files
- Log structured data beautifully
🧼 Clean Trick: Sorting Keys Too
print(json.dumps(data, indent=4, sort_keys=True))
💡 Sometimes the most powerful tools are the ones built in.
📖 For more tips and tricks in Python 🐍, check out
Packed with hidden gems, Python's underrated features and modules are real game-changers when it comes to writing clean and efficient code.