Way I found to prettify JSON messages from ngrep command:

sudo ngrep -t -W byline port 2012 -d lo | grep "^{" | jq .


We use to check the behavior of our app using ngrep, the messages inside the app uses JSON to share data. However trying to read JSON lines on console where a hard task so we often copy/paste to jsonlint.com to prettify, looking for way to prettify ngrep using stdin we found no guide to how to do it. Above is the way we found.

You need to install jq for this to work.

If you have a better way please add it as an answer.

  • Change port and/or device host as you need. – user2236409 Jul 25 '20 at 21:56

There is a JSON checker/pretty-printer that comes with Python, it can be used without any Python code like this:

python -m json.tool  [{infile} [{outfile}]]

Where {infile} and {outfile} default to stdin/stdferr.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.