ShotMark
Skip to Content

JSON Minifier

Strip whitespace and compress JSON to its smallest valid form.

JSON Input
Minified
Waiting for input

What is JSON Minifier?

A JSON minifier is a tool that strips every whitespace character outside string values from a JSON document, producing the smallest byte-equivalent representation while preserving full validity per RFC 8259. The output parses into the exact same data structure as the input but takes less bandwidth, less storage, and slightly less parser time.

This JSON minifier parses your input with the native JSON.parse and re-serializes it with JSON.stringify and no indentation argument. The round-trip guarantees the output is still valid JSON, drops every space, tab, and newline that the formatter added for human readability, and runs entirely in your browser so the payload never leaves your device.

Why use this JSON minifier?

  • Shrink API payloads and config files. Removing whitespace typically cuts JSON size by 20 to 40 percent, which matters for mobile bandwidth, edge caches, and request-size limits.
  • Pack data into URL params or headers. Minified JSON fits more comfortably inside query strings, cookies, and JWT claims where every byte counts against a hard limit.
  • Embed JSON inside other formats. A one-line minified payload pastes cleanly into a Bash heredoc, a YAML string value, or an HTML data attribute without escaping newlines.
  • Validate while you minify. The minifier round-trips through the parser, so any syntax error (trailing comma, unquoted key) surfaces immediately instead of getting silently shipped.
  • Stay private by default. Minification runs in your browser. The JSON never reaches a server, so secrets, tokens, and PII in your payload stay local.

How to use the JSON minifier

  1. Paste your formatted JSON into the input panel on the left.
  2. Click Minify.
  3. The output panel on the right shows the compressed single-line JSON. Click the copy icon to copy it.
  4. If the input has a syntax error, a red error banner appears above the panels with the parser’s message.

Before and after

A pretty-printed payload:

{ "user": { "id": 12, "name": "Ada Lovelace", "roles": ["admin", "owner"] }, "active": true }

Minified:

{"user":{"id":12,"name":"Ada Lovelace","roles":["admin","owner"]},"active":true}

The structure is identical, the byte count drops from 119 to 79, and every later parse produces the same object.

What the JSON minifier removes (and keeps)

CharacterInside stringsOutside strings
SpaceKeptRemoved
TabKeptRemoved
Newline (LF / CRLF)Kept (as escape)Removed
CommaKeptKept (required by grammar)
Quote (")Kept (escaped)Kept (required)
Colon (:)KeptKept (required)

The minifier never touches the contents of string values, so a string containing a newline ("line one\nline two") keeps that newline intact. It only strips formatting whitespace that the parser would have ignored anyway.

Common use cases

  • Backend developers reducing API response sizes. Minify JSON responses in production while keeping pretty-printed fixtures in tests, where readability matters.
  • DevOps engineers packing config into env vars. Compress a JSON config into a one-line value that fits inside a Kubernetes secret or a CI environment variable.
  • Mobile developers cutting cellular data usage. Minified payloads send fewer bytes over slow networks, which adds up across millions of requests.
  • QA engineers preparing test fixtures. Convert formatted sample data to minified form before pasting into a curl command or a Postman raw body.
  • Security engineers shrinking JWT claims. Minified custom claims leave more headroom inside JWT size limits enforced by edge proxies.

Frequently asked questions

Does minifying JSON make it faster to parse?

Marginally. Modern parsers like V8’s JSON.parse skip whitespace in microseconds, so the parse-time saving is negligible. The real saving is bandwidth: a minified payload transfers fewer bytes, which is measurable on cellular networks and at the CDN edge. For server-to-server calls inside the same data center, the saving is invisible.

Will minified JSON still validate?

Yes. The minifier round-trips your input through the native parser before re-serializing, so the output is guaranteed to be syntactically valid JSON per RFC 8259. If the original was invalid, the minifier reports the parser error instead of producing output.

What is the difference between minifying and gzipping JSON?

Minifying removes whitespace at the source. Gzipping compresses bytes at the transport layer. They stack: gzip on minified JSON is smaller than gzip on pretty-printed JSON, but the difference is small because gzip already collapses repeated whitespace efficiently. Always gzip JSON in production; minifying is a secondary win.

Can I un-minify the output back to pretty form?

Yes. Paste the minified JSON into a JSON formatter and it will re-indent with two spaces. The round-trip is lossless because minification only strips formatting whitespace, never modifies data.

Does the minifier preserve key order?

Yes. JavaScript’s JSON.parse preserves insertion order for string keys (and numeric keys are sorted by spec), and JSON.stringify writes them out in the same order. So the minified output keeps your original key sequence, which matters for tools that compare JSON by serialized form.

My JSON contains escaped Unicode. Does it survive?

Yes. The minifier passes through the parser, which decodes \uXXXX escapes into native characters, and JSON.stringify re-encodes only characters that require escaping. The output is byte-different from your input but represents the same string values.

Will minifying break a JWT or signed payload?

Yes, if the signature was computed over the original byte sequence. JWT signatures and HMAC-signed webhooks cover the exact bytes of the payload, so re-serializing (even losslessly) changes the bytes and invalidates the signature. Only minify before signing, never after.

Like this tool?

ShotMark captures what you do here, in one click.

The traces, payloads, and tests you run by hand? ShotMark grabs the whole bug and hands it to your AI agent.

Private beta accessFounding pricing lockNo spam ever