Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Beautifying JSON output in terminal - Visual Studio Code - Python

I would like to make the output of JSON string prettier in the terminal of VSC.

I'm currently using python 3.8.5 32 bit in a venv, and the latest version of VSC. I've got the python and python extension pack installed. I tried Prettify JSON but that doesn't seem to do anything.

So far I've tried using:

print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))

However this just produces a large string that is difficult to read Image of the output

I'm a relative beginner with Python and just started with VSC in the last couple of days.

like image 234
NathanB Avatar asked Oct 27 '25 02:10

NathanB


1 Answers

from pprint import pprint

pprint(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))
like image 178
Vishal Singh Avatar answered Oct 29 '25 16:10

Vishal Singh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!