⚡ QUICK LOOKUPjq Tips & CLI

jq Minify Command: How to Use the -c Flag (and Browser Alternatives)

Looking up “jq minify” means you want the exact flag that turns JSON into a single line. Copy the commands below, understand when to use them, and grab a browser-based fallback when jq isn't installed.

•4 min read•ConvertJSONCSV Team

TL;DR

Use jq -c / --compact-output to minify JSON.

It removes whitespace, newlines, and indentation so you get a single-line JSON string ready for logs or other CLI commands.

Minify a file

jq -c . input.json > output.min.json

Minify API responses

curl https://api.example.com/data | jq -c .

Why Developers Reach for jq -c

jq pretty-prints JSON by default, which is great for humans but bloats data in pipelines. The compact flag shines when you need to:

Trim log size

Smaller log files, smaller Git snapshots, fewer bytes in artifacts.

Safer pipelines

One-line output prevents multi-line JSON from breaking sed, awk, or CI secrets.

Faster transfers

curl → jq → curl chains become leaner when payloads have no whitespace.

The data itself is unchanged—only formatting disappears. jq, Node, Python, and observability tools read it just as before.

Bash-Ready jq Minify Examples

Covering related searches such as “jq compact output”, “bash minify json string”, and “linux json minify command line”.

Only minify a specific field

# Keep everything else pretty-printed, only compress ".data"
jq '.data |= (.|@json | fromjson)' payload.json | jq -c '.data'

Sort keys for deterministic diffs

jq -cS . config.json > config.sorted.min.json

Remove ANSI colors for strict scripts

curl https://api.example.com | jq -cM .

Combine -c (compact) with -M (monochrome) when piping into config files or downstream tools that dislike color codes.

jq -c vs. Online JSON Minifier

jq dominates automated pipelines, but sometimes you are on Windows or cannot install CLI tools. That's where our browser-based JSON Minifier steps in.

jq -c / --compact-output

  • âś… Perfect for Linux/macOS terminals and CI pipelines
  • âś… Script-friendly and deterministic
  • âś… Zero runtime dependencies after install
  • ⚠️ Terminal-only, no visual inspection

Online JSON Minifier (browser)

  • âś… Works on Windows, Chromebook, locked-down laptops
  • âś… Drag-and-drop UI with formatted + minified previews side by side
  • âś… 100% client-side, so nothing is uploaded
  • ⚠️ Manual interaction (not built for cronjobs)

Try it in seconds: Online JSON Minifier. Paste JSON, click “Minify”, and copy the single-line output.

Recommended Workflow

  1. Save a shell alias so nobody forgets the flag:
    alias jqmin='jq -c .'
  2. Use jq for CI pipelines, cronjobs, and any place JSON needs to stay within the terminal.
  3. Use the browser minifier when you need visual verification, you are on Windows, or you cannot install new CLI tools.

No jq? No Problem.

Our online JSON formatter/minifier runs entirely in the browser, never uploads your payload, and provides copy/download buttons for the minified output.

Open the Online JSON Minifier

Frequently Asked Questions

Does jq -c alter the actual data?

No, it only strips whitespace. Parsing the minified file yields the exact same JSON structure, so hashes and payload integrity remain intact.

What if jq isn't installed on my machine?

Use Python's standard library (python -m json.tool --compact) or our online minifier. Both run locally with no uploads.

Can I re-expand minified JSON later?

Absolutely. Run jq . file.min.json (without -c) or click “Format” inside our online tool to pretty-print it again for human review.

Minify JSON Instantly with ConvertJSONCSV.com

Keep jq for scripts, but fire up our browser-based formatter whenever you need to inspect, minify, and copy JSON with zero installs.

Open the Online JSON Minifier