Skip to content
cosmodev ~/tools/json-minify

JSON에서 모든 공백을 제거해 가장 압축적인 직렬화를 만듭니다. 압축하면서 검증하며, 브라우저에서 완전히 동작하고 정확한 입력을 담은 공유 링크를 제공합니다.

예시:

(문서는 영어)

What it does

Rewrites a JSON document in its smallest valid form: every space, newline, and indentation character between tokens is removed. The input is parsed first, so the output is guaranteed to be valid JSON carrying identical data. Invalid input produces a red error box, never broken output. A savings badge in the output header reports the before and after size in bytes and the percentage saved, computed to one decimal — green when bytes were removed, neutral when the input was already compact. Everything runs locally in your browser.

How to use it

  1. Paste JSON into JSON input (left), or tap a chip under Try: — Pretty config, Whitespace-heavy, or Already minified — to see each case minify. Sample loads a demo document; Clear empties the box.
  2. The minified document appears live in Minified (right), with the savings badge above it: N bytes → M bytes · saved X%.
  3. Copy takes the output; Download saves it as minified.json (offered only when the input is valid JSON).
  4. Copy share link encodes your input in the URL. Opening that link puts the input straight back into the tool.

Examples

Tap Sample:

78 bytes → 64 bytes · saved 17.9% — {"name":"CosmoDev","tools":["json-minify","base64"],"open":true}

The Whitespace-heavy chip shows both rules at once — padding between tokens vanishes, spaces inside a string survive:

{ "greeting" : "hello world" } → {"greeting":"hello world"} (67 bytes → 41 bytes · saved 38.8% for the full chip document)

An already-minified document stays as it is:

{"a":1,"b":[1,2]} (17 bytes) → {"a":1,"b":[1,2]} (17 bytes) · saved 0%

Minification can make a document longer, because JSON number formatting is normalized on re-serialization:

{"a":1E3} (9 bytes) → {"a":1000} (10 bytes) · saved -11.1%

The negative number is not a bug; it is the honest size difference.

How JSON minification works

Minification removes whitespace only. It shortens no keys, drops no data, and reorders nothing: parse the input, then serialize it back with zero separator characters. The operation is exactly reversible — formatting the minified document restores a readable form with the same content.

Because commas, colons, and brackets already delimit tokens, every whitespace character between them is optional:

Pretty Minified Removed
{\n "a": 1\n} {"a":1} newline, indent, space after :

The one exception is whitespace inside a quoted string: it is data, and it survives untouched. A sentence inside a value keeps its spaces after minification.

Minified payloads matter wherever bytes are counted repeatedly: config files fetched by browsers, API responses served at scale, JSON embedded in a URL or a single-line script tag, and command-line one-liners where newlines break shell quoting.

Good to know

  • Private: parsing and serialization run locally; nothing is sent anywhere.
  • Equivalent to JSON.stringify(JSON.parse(input)).
  • Watch the sign: 0 or negative savings means the input was already compact. The output is still the canonical form.
  • Share links carry the full input in the URL — very large documents make very long links.
  • Related tools: JSON Formatter, JSON Validator, JSON ↔ CSV Converter.
소스 코드14개 언어

100% 클라이언트 측 · 데이터는 브라우저 밖으로 나가지 않습니다. 도움이 되었나요? 팀원에게 공유해 보세요.