In the spirit of the last post about formatting unformatted JSON there are occasions when you need to process and format JSON in a hurry on a non-developer machine.

Take the following example, which uses the excellent service that generates test JSON via an API endpoint

Using your favourite command line tool, fetch the JSON from the following url https://microsoftedge.github.io/Demos/json-dummy-data/64KB-min.json

On my machine, I run the following request using curl

curl https://microsoftedge.github.io/Demos/json-dummy-data/64KB-min.json

The response is as follows:

MinifiedJson

Note: don’t use httpie for the purposes of this demo - httpie will format the json for you!

Also, If you are on Windows on PowerShell, run the command as follows:

curl.exe https://microsoftedge.github.io/Demos/json-dummy-data/64KB-min.json

Note this is curl.exe and not curl. In Powershell, curl is an alias for Invoke-WebRequest

To format the json, pipe it to the very useful jq program.

jq is not installed by default, so install it using your favourite method (Winget or chocolatey on Windows, homebrew on OSX, apt on Linux)

curl https://microsoftedge.github.io/Demos/json-dummy-data/64KB-min.json | jq

You should see something like this on OSX:

jsOSX

And something like this on Windows

Happy hacking!