JSON Minify
Minify and compress your JSON data to reduce payload size.
Compress JSON without guessing what is removable
JSON minification removes formatting characters that carry no data: indentation, line breaks, and spaces between tokens. The result is a compact single-line representation suited to transport, embedding, or storage where human readability is secondary. This JSON minifier first parses the source, then serializes the parsed value without pretty-print spacing. That parse-and-serialize approach is safer than blindly deleting every space because spaces inside strings remain intact.
Two optional transformations address common developer inputs. Strip Comments accepts JavaScript-style // line comments and /* ... */ block comments before parsing. Escape quotes (Stringify) serializes the compact JSON one additional time, producing a quoted string whose internal double quotes are escaped. Both options rerun automatically as the input or setting changes.
The minification pipeline
The browser applies the following sequence:
- It reads the exact input and measures its UTF-8 byte length.
- If comment stripping is enabled, a small state-based scanner removes line and block comments while attempting to leave comment-like text inside quoted strings untouched.
- The cleaned text is passed to
JSON.parse. Invalid syntax stops processing and displays the parser error. JSON.stringifycreates compact JSON with no indentation or token-separating whitespace.- If quote escaping is enabled,
JSON.stringifyruns on that compact string, adding outer quotes and escaping characters required by a JSON string literal. - The tool measures output bytes and reports original size, minified size, percentage reduction, and bytes saved.
The statistics use TextEncoder, so they represent UTF-8 bytes rather than JavaScript character count. Non-ASCII characters may occupy more than one byte. The original measurement includes comments and whitespace exactly as pasted; this makes the displayed reduction useful for comparing input and final output.
A commented input example
With Strip Comments enabled, this configuration-like source can be processed even though comments are not legal JSON:
{
// Runtime endpoint selected by the deployment
"service": "catalog",
"baseUrl": "https://api.example.com/v2/items",
/* Retry settings are shared by workers. */
"retry": {
"enabled": true,
"attempts": 3
},
"labels": ["public api", "inventory"]
}
The compact result is:
{"service":"catalog","baseUrl":"https://api.example.com/v2/items","retry":{"enabled":true,"attempts":3},"labels":["public api","inventory"]}
Notice that the https:// sequence remains inside the URL and the space in "public api" is preserved. Only comments and insignificant formatting are removed.
With Escape quotes (Stringify) selected, the output instead becomes a JSON string literal similar to:
"{\"service\":\"catalog\",\"baseUrl\":\"https://api.example.com/v2/items\",\"retry\":{\"enabled\":true,\"attempts\":3},\"labels\":[\"public api\",\"inventory\"]}"
That escaped form is not an object anymore. Parsing it once returns the compact JSON text; parsing that text again returns the object. Use it only when the destination expects JSON encoded inside a string.
Operating the online JSON minifier
Paste formatted JSON into Input JSON, or choose Load Sample to explore the comment behavior. The minified panel updates immediately. A successful conversion shows Minified and enables Copy and Download. The dashboard appears below the editors with four byte-oriented metrics.
Leave Strip Comments enabled for JSON-with-comments copied from configuration or source files. Turn it off when comments should cause a strict parsing failure, or when diagnosing whether an upstream producer is sending standards-compliant JSON. The setting is enabled initially.
Enable Escape quotes (Stringify) only for an embedding use case. The download filename changes with this choice: normal compact output downloads as minified.json, while escaped output downloads as minified_escaped.txt. Clear removes the input, result, error, and size statistics.
Where compact JSON helps
Compare payload overhead during development
The savings dashboard quantifies how much of a sample consists of presentation whitespace. This is useful when reviewing fixtures, static data files, or generated payloads. It is not a network benchmark: HTTP compression such as gzip or Brotli can reduce repeated whitespace and property names differently, and protocol headers are not included.
Prepare a single-line environment value
Some deployment interfaces and .env workflows are easier to manage with one-line JSON. Minify the object, then use the plain output if the consumer parses JSON directly. Use escaped output only if the surrounding configuration syntax requires a quoted JSON string, and verify how that system handles its own quoting layer.
Embed data in a test or request
Compact output is convenient for a curl body, a unit-test constant, or a message-queue sample. It reduces visual noise when the structure is already understood. For source code, a language-specific serializer is generally safer than manually assembling strings.
Normalize JSON before text-based checks
Parsing and serializing removes layout differences, so two files that differ only in indentation may become the same text. Object keys are not sorted, however, so this is not canonical JSON and cannot replace a semantic JSON comparison.
Understanding the reported savings
Original Size is the UTF-8 size of the source before comments are stripped. Minified Size is the UTF-8 size of the final panel, including outer quotes and escape backslashes when stringify mode is active. Bytes Saved never displays a negative number; it is clamped to zero. Size Reduction is bytes saved divided by original bytes.
Escaped output can be larger than ordinary minified JSON because each property quote gains a backslash and the whole document gains outer quotes. In that situation, the dashboard reports zero bytes saved rather than a negative reduction. The escaped option solves an encoding problem, not a compression problem.
Whitespace-heavy pretty JSON usually shows a meaningful reduction. Already minified input may show no reduction. Documents dominated by long string values also shrink less because string contents cannot be discarded.
Troubleshooting failed minification
Parsing Error appears after pasting JSON
Read the detailed error below the input editor. Check for trailing commas, single quotes, missing closing brackets, or unquoted keys. Comment removal does not repair any of those constructs.
Comments still cause an error
Confirm Strip Comments is checked. An unterminated block comment or unusually escaped string can still make the cleaned text invalid. The comment scanner is designed for common // and /* ... */ cases, not the full grammar of JavaScript or JSON5.
A URL or comment marker in a string changed unexpectedly
Quoted URLs are ordinarily retained because the scanner tracks whether it is inside a string. Complex backslash sequences immediately before a quote can be difficult for a lightweight scanner. For critical configuration, remove comments with the source format’s own parser and paste strict JSON.
The output has backslashes everywhere
Disable Escape quotes (Stringify). Those backslashes intentionally encode the compact document as a string. Plain minified JSON starts with { or [ for object and array inputs, rather than with an outer double quote.
Size reduction is zero
The source may already be compact, may consist mostly of values, or may have grown due to escaped-string output. Minification does not compress value data and does not apply gzip, Brotli, dictionary coding, or key shortening.
Scope and limitations
This tool accepts one complete JSON value after optional comment removal. It does not process newline-delimited JSON, concatenate documents, JSON5 features, or JavaScript expressions. Parsing can normalize number spelling and escape representation. Duplicate object keys cannot be preserved reliably because the parser resolves the object before serialization.
The operation is in-browser and requires enough memory for the source, parsed value, and output at once. Extremely large payloads may make the page slow. It also does not guarantee canonical key order, cryptographic stability, or byte-for-byte reversibility to the original formatting.
JSON Minify FAQ
Is minified JSON still valid JSON?
Yes, when quote escaping is off. Whitespace between JSON tokens is optional, so removing it does not change the parsed value. With quote escaping on, the result is valid JSON representing a string, not the original object or array directly.
Does this remove spaces from string values?
No. A value such as "given name" retains its internal space. The tool parses the document rather than applying a global whitespace replacement.
Can it strip both line and block comments?
Yes. With the default option enabled, it handles // through the end of a line and /* ... */ blocks. JSON comments are an input convenience here; the resulting plain output contains none.
Does the tool shorten property names?
No. Renaming keys would change the data contract. It removes formatting overhead only and preserves parsed keys and values.
Why does the escaped download use a text extension?
Escaped mode produces a string representation intended for embedding, so the file is named minified_escaped.txt. Standard mode creates minified.json with an JSON media type.
Is the percentage the same as gzip savings?
No. It compares raw UTF-8 input and output byte lengths. Transport compression is a separate layer and should be measured using the actual server, content encoding, and payload distribution.
Can I use the output for signing or hashing?
Only if every participant explicitly agrees on this exact serialization behavior. The output is compact but not a formal canonical JSON scheme, and key order is not alphabetically normalized.