Languages
[Edit]
EN

Python pretty print JSON command line

5 points
Created by:
Root-ssh
178290

Hi, today we would like to show you how to pretty print JSON using python from command line level.

Quick solution:

Practical example:

In above example we can use: python -m json.tool

We use echo command to print our JSON and we pass it to python json tool.

Python JSON pretty print and save to file

Edit

If we want to save our pretty printed JSON to file we just need to redirect output to file.

In order to do that we can use below commnad as an example:

Practical example:

Python json pretty print entire file

Edit

 

1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join