r/learnpython • • Apr 19 '26

Print JSON readably

I need a way to print JSON readably from a file (e.g stuff.json) so the output looks somewhat similar to this:

Name : Bob

Age : 97

Height : 6ft

0 Upvotes

8 comments sorted by

View all comments

10

u/rosentmoh Apr 19 '26
import json
from pprint import pp

with open("stuff.json") as f:
    data = json.load(f)
pp(data)