Free JSON Minifier
Paste JSON to strip every byte of unnecessary whitespace and get the smallest valid equivalent, with a live before/after byte-size and percent-saved comparison.
Quick answer
To minify JSON, paste it into the box. The tool parses it with the browser's JSON engine to confirm it's valid, then re-serializes it with JSON.stringify using no indentation, removing all spaces, tabs, and line breaks between tokens. It also reports the original size, minified size, and the percentage of bytes saved.
Formula & method
Minified output
minified = JSON.stringify(JSON.parse(input)) // no indent argument, so all inter-token whitespace is removed
- input — the original JSON text you paste
- minified — the compact, single-line valid JSON output
Bytes saved (percent)
saved% = (1 - minifiedBytes / originalBytes) * 100
- originalBytes — UTF-8 byte length of the input
- minifiedBytes — UTF-8 byte length of the minified output
Your text is parsed with the browser's native JSON.parse, which both validates the syntax and builds an in-memory value. If parsing fails, the parser's exact error message (with the position of the problem) is shown so you can fix it. If it succeeds, the value is re-serialized with JSON.stringify(value) and no space argument, which emits the most compact valid form: no indentation, no newlines, and no spaces after colons or commas. The tool measures the original input and the minified output in UTF-8 bytes (using TextEncoder, the same way they would be stored or transmitted) and reports the byte counts plus the percentage saved. Whitespace inside string values is preserved exactly, because that whitespace is meaningful data rather than formatting. Everything runs locally in your browser, so your JSON, including any tokens or credentials, never leaves your device.
Examples
- Input
- { "name": "Ada", "age": 36 }
- Result
- {"name":"Ada","age":36}
- Why
- All spaces between tokens are removed. The input is 28 bytes and the minified output is 23 bytes, saving 17.9%.
- Input
- { "a": 1, "b": [ 2, 3 ] }
- Result
- {"a":1,"b":[2,3]}
- Why
- Newlines, indentation, and the spaces inside the array are stripped. 29 bytes becomes 17 bytes, saving 41.4%.
- Input
- [ { "id": 1, "ok": true }, { "id": 2, "ok": false } ]
- Result
- [{"id":1,"ok":true},{"id":2,"ok":false}]
- Why
- Each element is collapsed onto one line with no padding. 57 bytes becomes 40 bytes, saving 29.8%.
- Input
- { "a": 1, }
- Result
- Error: Expected double-quoted property name in JSON at position 10
- Why
- JSON forbids a comma before a closing brace, so parsing fails and the position of the error is reported instead of an output.
When to use this tool
- Shrinking a JSON payload before sending it over the network or storing it to cut bandwidth and size.
- Confirming a config or API body is valid JSON while also producing its compact form.
- Embedding JSON into a single-line string, environment variable, or data attribute where line breaks would cause problems.
Common mistakes
- Expecting whitespace inside string values to disappear. Only whitespace between tokens is removed; spaces and newlines inside a quoted string are real data and are kept.
- Pasting a JavaScript object, JSON5, or JSONC with comments, single quotes, or trailing commas. Strict JSON rejects these, so minifying fails until you fix the syntax.
- Assuming minified JSON is encrypted or obfuscated. It is the same data on one line, fully readable, just smaller.
Frequently asked questions
What does minifying JSON actually remove?
It removes every byte of whitespace that sits between tokens: indentation, line breaks, and the spaces after colons and commas. The keys, values, and structure stay identical, so the result parses to exactly the same data.
Does minifying change my data or lose precision?
No. The tool parses then re-serializes, so the data is unchanged. Numbers, strings, booleans, null, nesting, and key order are preserved. Only formatting whitespace is dropped.
Is whitespace inside strings removed too?
No. Spaces, tabs, and newlines inside a quoted string value are part of the data, so they are kept exactly. Only whitespace outside of strings is stripped.
How is the percentage saved calculated?
The tool measures the original and minified text in UTF-8 bytes and computes 1 minus minified bytes divided by original bytes, as a percentage. UTF-8 bytes are used because that reflects real storage and transfer size, especially for non-ASCII characters.
Is my JSON uploaded to a server?
No. Parsing, minifying, and the size comparison all run in your browser using its built-in JSON engine. Sensitive payloads, tokens, and credentials never leave your device.
Why does it reject my JSON with comments or trailing commas?
Standard JSON, defined by RFC 8259, does not allow comments, single quotes, unquoted keys, or trailing commas. JSON5 and JSONC allow some of these, but they are not valid strict JSON, so they must be cleaned up before minifying.
Can it handle very large JSON files?
It runs in your browser, so the practical limit depends on available memory. Files up to a few megabytes are fine; for very large files a streaming command-line tool such as jq is more reliable.
Sources & references
- RFC 8259 — The JavaScript Object Notation (JSON) Data Interchange Format
- MDN — JSON.stringify()
- json.org — Introducing JSON
External references open in a new tab. We are independent and not affiliated with these organizations.
- ✓ Free to use
- ✓ No sign-up required
- ✓ Runs entirely in your browser — nothing is uploaded.
- ✓ Formula and method shown above
Provided “as is” for general information only — results may be inaccurate, so verify before you rely on them. No warranty; use at your own risk.
Built and reviewed by HIFreeTools against the formula shown above and any authoritative references cited on this page. See our methodology and editorial standards.
Related tools
- JSON Formatter & ValidatorDeveloper
- JSON ValidatorDeveloper
- Base64 Encoder & DecoderDeveloper
- URL Encoder & DecoderDeveloper
- UUID GeneratorSecurity
- Unix Timestamp ConverterDeveloper
Embed this tool on your site
Free to embed, no sign-up. Paste this code where you want the json minifier to appear: