Search code examples
jsonlinuxunixcommand-linepretty-print

Trouble pretty-printing large json file on linux command line with jq


I am trying to pretty-print and scroll through sections of an extremely large (tens of gigabytes) human-unreadable json file with jq on the command line.

less bigFile.json | jq

works but just makes it fly by.

I tried to pipe it back into less like this:

less bigFile.json | jq | less

but it produced some kind of error.

How do you make this work?


Solution

  • The command should look like this:

    jq -C . bigfile.json | less -r
    

    If that exhausts all your memory you might want to try the -B option of less or even better, use jq to filter out the interesting parts.