↑ ↓ select, Enter open, Esc close

Pretty-print JSON with indentation and colors

Adjust the values, the command updates live
user@server
jq . composer.json

The . filter outputs the complete document unchanged, but neatly indented. If the JSON is invalid, jq reports the position with line and column and exits with an error code. Works just as well in a pipe, for example curl -s https://example.com/wp-json/ | jq ..

Note: jq is not preinstalled: apt install jq. Conversely, -c produces compact single-line JSON.

Also searched as

  • pretty print json command line
  • format json file linux
  • validate json in terminal

Related one-liners

All in Text processing

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.