Minify JSON Online

Remove whitespace from JSON to reduce payload size.

What This Tool Does

This tool takes any JSON text, parses it, and re-serializes it with JavaScript's native JSON.stringify(parsed) — with no indentation argument. That strips every insignificant space, tab, and newline between tokens, leaving the most compact valid representation of the same data on a single line.

Because the input has to be parsed before it can be re-serialized, this tool also validates JSON syntax as a side effect. If your input isn't valid JSON, parsing fails and you get a clear error message instead of mangled or partial output.

How to Use It

  1. Paste your JSON — pretty-printed, hand-typed, or copied from a file or API response — into the Input box.
  2. Click Run.
  3. If the JSON is valid, the compact, whitespace-free version appears in the Output box.
  4. If the JSON is invalid, an error message appears below the boxes describing what failed to parse.
  5. Copy the minified result from the Output box, or click Clear to start over.

Worked Example

Input (formatted, 143 characters):

{
  "id": 101,
  "name": "Widget",
  "tags": [
    "a",
    "b"
  ],
  "active": true,
  "meta": {
    "price": 9.99,
    "inStock": null
  }
}

Output (minified, 94 characters):

{"id":101,"name":"Widget","tags":["a","b"],"active":true,"meta":{"price":9.99,"inStock":null}}

That's a drop from 143 characters to 94 characters — roughly a 34% size reduction — on a small, already-tidy example. Real-world files with deep nesting and heavy indentation typically save even more.

Why Minify JSON?

Note on Token Efficiency vs TOON

Minifying reduces byte size for network transfer and storage, but it does little for LLM prompt token counts — tokenizers already collapse most whitespace runs, so a minified and a pretty-printed version of the same JSON often tokenize almost identically. If you're specifically optimizing for LLM context size or API cost, restructuring the data format matters far more than removing whitespace. TOON's tabular encoding is published at roughly a 42.6% average token reduction versus JSON for the same data — see the JSON to TOON Converter for that use case.

FAQ

Does minifying change the data?

No. Only insignificant whitespace between tokens is removed. Every key, value, array, and object is preserved exactly as-is — the data is identical, just written more compactly.

Does this also validate my JSON?

Yes. The input is parsed with JSON.parse before being re-serialized, so invalid JSON throws a clear error instead of producing output.

Is my data uploaded anywhere?

No. Minification happens entirely in your browser with JavaScript's built-in JSON parser — nothing is sent to a server or stored.

Will minifying reduce LLM prompt token counts?

Only marginally. Tokenizers already handle whitespace efficiently, so minifying mostly helps byte size and network transfer, not token count. For LLM context and cost optimization, restructuring the data (such as converting to TOON) has a much bigger impact.

Can I reverse minification back to readable JSON?

Yes, minification is lossless. Use the JSON Formatter & Prettifier tool to pretty-print it back into indented, readable form.

Related Tools & Guides