Overview
Strips all insignificant whitespace from JSON to produce the smallest valid payload, showing the original and minified character counts and the bytes saved. The conversion is parse-then-serialize, which means invalid input is caught and reported rather than mangled. The minified output appears live and copies with one click.
How It Works
Paste formatted JSON into the input panel. The minified single-line result appears below, together with badges showing the input size in characters, the output size, and the exact bytes and percentage saved. If the input is not valid JSON, the output panel shows Invalid JSON instead of a partial result, so a broken payload is never silently truncated. Click the output to copy it.
Step-by-Step Usage Guide
- Paste pretty-printed JSON into the input panel.
- Read the saved-bytes badge to see how much whitespace was removed.
- Verify the output panel shows minified JSON, not the Invalid JSON message.
- Click the output to copy the single-line payload for embedding or transfer.
Technical Specifications & Standards
Minification is lossless here because RFC 8259 defines whitespace between tokens as insignificant: the spaces, tabs, and newlines that pretty-printing adds around braces, colons, and commas carry no data. The implementation takes the honest route of JSON.parse followed by JSON.stringify with no spacing argument, which does more than delete whitespace and has visible side effects worth knowing before you diff the output. Number formatting is normalized: 1.0 serializes as 1, 1e2 as 100, and values beyond double precision keep only what a float64 can hold, so extremely precise decimals can change in the last digits while remaining equal as numbers. String escapes are re-chosen by the serializer, so an escaped letter may be emitted literally, and key order is preserved because JavaScript objects preserve insertion order for string keys. The saved-bytes figure is measured in JavaScript string characters, not UTF-8 bytes, so multi-byte content makes the real on-wire saving differ; after gzip, the further benefit of minification shrinks a lot, since repeated indentation is exactly what compressors squeeze best. When input fails to parse, the Invalid JSON message is the signal to fix the source rather than a partial output to ship.
Targeted Use Cases
- Preparing compact JSON for request bodies, cache entries, or storage keys.
- Measuring how much overhead pretty-printing adds to a config or data file.
- Validating JSON implicitly: an Invalid JSON result catches syntax errors before minifying.
- Producing single-line fixtures for tests that compare payloads as strings.
Notes & Gotchas
- Minify only after validating, since the parse step rejects invalid JSON rather than stripping characters blindly.
- Do not expect large wins after gzip; transport compression already removes most whitespace redundancy, so measure end to end.
- Watch number formatting: 1.0 and 1.00 both serialize as 1, which is data-identical but not text-identical to the source.
- Keep the pretty-printed original as your source of truth and minify as a build or send step, not as the storage format.
Frequently Asked Questions
Does minifying change my data?
No for the data itself. Only whitespace outside strings is removed, and the values parse identically. Textual differences can appear in number formatting (1.0 becomes 1) and in how escapes are written, but both parse to the same values.
What happens with invalid JSON?
The output shows Invalid JSON and nothing is minified. Because the tool parses before serializing, a syntax error is caught instead of producing a subtly broken result.
Why does 1.0 become 1 in the output?
The tool parses to JavaScript numbers and re-serializes, and the number 1.0 and 1 are the same double value. JSON makes no distinction between them textually, so the serializer prints the shortest form.
Is the savings percentage based on bytes on the wire?
It is based on JavaScript string characters, which equals bytes for ASCII content. With non-ASCII text or after gzip transport, the real transfer saving differs, so measure end to end if it matters.