Today I learned

Inspecting JSON output in the command line

View JSON output in the command line using jq together with less. This makes JSON output more readable.

Setting it up

Use jq with less to make view JSON output better. Using -C with jq will force colors, and -R with less will print colors.

# For bash and zsh shells
alias jless='jq -C . | less -R"
# For fish shell
abbr jless 'jq -C . | less -R"

Use this jless alias to make better sense of Docker's output:

docker ps --format '{{ json . }}' | jless

You have just read Inspecting JSON output in the command line, written on March 24, 2019. This is Today I Learned, a collection of random tidbits I've learned through my day-to-day web development work. I'm Rico Sta. Cruz, @rstacruz on GitHub (and Twitter!).

← More articles