Skip to content
UniKit

JSON minify

Minify JSON into a single compact line and compare characters, bytes and the reduction ratio before and after; invalid JSON is reported with exact line and column.

Runs in your browserEvery computation happens in your browser — your data never leaves this device.

Minified output

What this tool does

  • Collapse pretty-printed JSON onto a single line before putting it into an environment variable, a command-line argument or a one-line config entry, so line breaks cannot cut the value in half.
  • Measure the saving: the panel below the output shows characters, bytes and the reduction ratio before and after minifying.
  • JSON copied out of documentation usually carries extra indentation; minify it before comparing strings or hashing it.
  • Produce a compact request body for curl, Postman or a log line.

Example

Input

{ "name": "UniKit", "tags": [ "json", "minify" ], "meta": { "stable": true } }

Output

{"name":"UniKit","tags":["json","minify"],"meta":{"stable":true}}

Statistics: 78 characters / 78 bytes before, 65 characters / 65 bytes after, 13 bytes saved and a 16.67% reduction. Only structural whitespace is removed; spaces inside strings are preserved exactly.

Frequently asked questions

Why is the reduction sometimes 0%?

Because the input was already compact, or whitespace makes up a tiny fraction of it. Minifying only deletes whitespace between keys and values, between array elements and around brackets; it never touches string contents, so an already single-line document keeps the same length.

Is this the same as gzip compression?

No. This removes human-readable whitespace and the output is still valid JSON text, so the saving is limited to layout characters. gzip and brotli are real binary compression algorithms that shrink repeated content much further but produce unreadable output; the two can be combined.

Are spaces and newlines inside strings removed?

No. Only whitespace outside JSON structure is removed; spaces, tabs and \n escape sequences inside double quotes are preserved, so the minified document is semantically identical to the original.

What happens with invalid JSON?

The tool validates before minifying, so bad input never produces a wrong result. Instead you get the line, column and reason — unexpected end of input, object keys must be double-quoted strings, extra content after the JSON value. A leading UTF-8 BOM is ignored automatically.

Is the JSON uploaded anywhere?

No. Everything runs in your browser, no network request is made, it works offline, and the JSON you paste is never recorded or stored.

Keywords:jsonjson 压缩json minifyjson 紧凑compress jsonminify压缩率size 对比

Related tools