Python (Scripting) - Parse JSON using json.tool

by
Jeremy Canfield |
Updated: November 25 2024
| Python (Scripting) articles
There are a number of different ways to parse JSON.
- json.load - parse a JSON file
- json.loads - parse JSON (key:value pairs)
- json.dumps - convert a dictionary into json
- json.tool - parse JSON on the command line (this article)
- .json() filter - parse JSON results
The python -m json.tool command can be used to produce human friendly JSON output on the command line.
~]$ echo '{ "foo": "Hello", "bar": "World" }' | python -m json.tool
{
"bar": "World",
"foo": "Hello"
}
Did you find this article helpful?
If so, consider buying me a coffee over at