How to Pretty Print JSON file in Linux Shell Script

Channel: Linux
Abstract: send the json content to the json_pp command via the pipe. You will find the results in a pretty formatI have a file fruit.json conaiting some json co

The json_pp is a command line utility available in Linux systems to print JSON output in pretty format. It can format the JSON content in file or results of other commands by passing with the pipe.

For example, I have a file fruit.json conaiting some json content but not in proper format.

cat fruit.json

{"fruit": "Apple", "size": "Large","color": "Red"}

Now, send the json content to the json_pp command via the pipe. You will find the results in a pretty format, which can be easily read.

cat myfile.json | json_pp

Output:

{
   "color" : "Red",
   "fruit" : "Apple",
   "size" : "Large"
}

Ref From: tecadmin

Related articles