jq is a command line tool to process JSON documents with loads of features.
If you just want quick (re-)indentation, use one of these Python powered poor man's alternatives:
python -c "import json,sys;json.dump(json.load(sys.stdin),sys.stdout,indent=2)" < data.json
python -c "import json,sys,pprint;pprint.pprint(json.load(sys.stdin))" < data.json
Examples:
$> echo '{"foobar the xuv wih":[1,2,3,{"hello":["world","earth","apple","orange","banana"]}]}' > data.json
$> python -c "import json,sys;json.dump(json.load(sys.stdin),sys.stdout,indent=2)" < data.json
{
"foobar the xuv wih": [
1,
2,
3,
{
"hello": [
"world",
"earth",
"apple",
"orange",
"banana"
]
}
]
}
$> python -c "import json,sys,pprint;pprint.pprint(json.load(sys.stdin))" < data.json
{'foobar the xuv wih': [1,
2,
3,
{'hello': ['world',
'earth',
'apple',
'orange',
'banana']}]}