/

JSON Minifier

Processed Client Side

Strip all whitespace to compress JSON for production. See exactly how many bytes you save.

Input · 16 lines · 337 B
16 lines · 337 B
Length: 337Lines: 16Size: 337 BytesCursor: 1:1
Minified
Minified266 B
Length: 266Lines: 1Size: 266 BytesCursor: 1:1
337 B → 266 BSaved 71 B · 21% smaller

Bookmark this tool now — skip the search next time you need it.

About JSON Minifier

This tool runs entirely in your browser. Whatever you paste is processed on your own device and is never uploaded, logged, or sent to any server.

The JSON Minifier strips every space, newline, and indent out of a JSON document and tells you exactly how many bytes that saved. Formatting exists for human readers, not for parsers: a pretty-printed config or API fixture is routinely 20–40% whitespace, and none of it survives JSON.parse. Paste a document, press Minify, and you get the compact single-line form together with a before → after byte count and the percentage saved. An “Escape as string” toggle goes one step further and wraps the minified result in a JSON string literal, ready to embed inside another JSON document, a shell variable, or a database column. Anything that will not parse is reported with the failing line highlighted.

Key features

  • One-click minification of any valid JSON document down to a single compact line
  • Byte-accurate readout: original size, minified size, bytes saved, and the percentage smaller
  • Sizes measured in real UTF-8 bytes, so emoji and non-Latin text are counted the way a server counts them
  • “Escape as string” toggle that wraps the minified output as a JSON string literal for embedding
  • Parse errors shown with the parser’s message and the offending line highlighted in the input editor
  • Syntax highlighting on both the input and the minified output
  • Live line count and byte size on the input pane as you type
  • Copy the result in one click, or Clear to start again
  • Runs entirely in your browser — payloads containing tokens or customer data never leave your machine

How to use it

  1. Paste or type your JSON into the input pane; the line count and size update as you go.
  2. Press Minify. Valid JSON is compacted immediately; anything malformed reports the error and highlights the line.
  3. Read the size row underneath — original → minified, plus the bytes and percentage saved.
  4. Switch on “Escape as string” if the result needs to sit inside another JSON document or a string constant.
  5. Copy the output and paste it wherever the compact form is needed.

Tips & common mistakes

  • Minifying changes nothing a parser can see — same keys, same values, same order. It only removes the whitespace, so it is always safe to send minified JSON to an API that accepts JSON.
  • Do not minify files that humans edit. package.json, tsconfig.json, and application config belong pretty-printed in the repository; minification is for what goes over the wire or into storage.
  • If the transport already uses gzip or Brotli, most of the whitespace cost has been paid for you — repetitive indentation compresses extremely well. Minifying still helps for uncompressed request bodies, localStorage, and JSON embedded inside other formats.
  • How much you save tracks nesting depth and indent width: a deeply nested document indented with 4 spaces can drop by well over a third, while a flat one barely moves.
  • Use “Escape as string” when a field in one JSON document has to hold another JSON document — a webhook body stored as a string, or a config value read back with a second parse.
  • Byte counts are UTF-8, not characters. An accented letter costs two bytes and most emoji cost four, which is why the size may exceed the character count.
  • JSON has no comments. If your file contains // or /* */ it is JSONC, and it must be stripped before this or any other strict parser will accept it.

Related tools

Browse all 24 JSON tools

Frequently asked questions

10

Paste your JSON into the input pane and press Minify. The compact single-line version appears on the right along with the number of bytes and the percentage you saved.

No. Only whitespace between tokens is removed, so the keys, values, and their order are identical. A parser produces exactly the same object from the minified form.

Typically 20–40% for a pretty-printed document, depending on nesting depth and indent width. Deeply nested files indented with 4 spaces save the most; flat files barely change.

No. Parsing and minification run in your browser using the native JSON engine, so payloads containing access tokens or customer data never leave your machine.

It wraps the minified JSON in a string literal, escaping the quotes inside it. Use it when the JSON has to be stored inside a field of another JSON document, a config value, or a shell variable.

Less so — compression already handles repetitive whitespace well. It still helps for uncompressed request bodies, data kept in localStorage, and JSON embedded inside another format.

A trailing comma after the last item is the most common cause, followed by single quotes instead of double quotes and unquoted keys. The tool highlights the line where the parser gave up — the mistake is often on the line above.

No. Comments are not part of the JSON specification, so a file using // or /* */ is JSONC and must have them stripped before any strict parser, including this one, will read it.

There is no fixed limit — the constraint is your browser’s memory. Documents of a few megabytes minify without trouble; very large files may take a moment to render in the editor.

Run it through the JSON Formatter, which re-indents it with your choice of spacing. Minification loses only whitespace, so nothing is missing from the restored version.