Bash

Pretty-Print JSON from cURL

admin by @admin ADMIN
4d ago
May 31, 2026
Public
0 0 up · 0 down Sign in to vote
Pipe API responses through jq for syntax-colored, indented output. Also great for extracting specific fields without writing a parser.
Bash
Raw
# Pretty-print the whole response
curl -s https://api.github.com/users/torvalds | jq .

# Extract a specific field
curl -s https://api.github.com/users/torvalds | jq -r .login

# Get an array, then iterate keys + values
curl -s https://api.github.com/users/torvalds/repos | jq -r '.[].name' | head

# Compose into a custom shape
curl -s https://api.github.com/users/torvalds/repos | \
  jq '[.[] | {name, stars: .stargazers_count, lang: .language}]'

# Without jq — readable enough for quick checks
curl -s https://api.example.com/data | python3 -m json.tool
Tags

Save your own code snippets

Create a free account and build your private vault. Share publicly whenever you want.