What is JSON minification?
JSON allows whitespace between its tokens. Pretty-printers add indentation and line breaks so that a person can read the structure, and that formatting usually dwarfs the data itself in a small document. On a typical response the whitespace can easily be half or more of the file.
Minification strips that formatting away. Every space, tab, carriage return and newline that appears between a brace, a colon, a comma or a value is deleted, and the result is written as one continuous line. Nothing is renamed, reordered or rounded - the document still means exactly the same thing, it just takes up less room.
That is why a JSON compressor and a JSON minifier are two names for the same job. The result is useful for API responses that travel over a network, for JSON embedded in a URL or a query string, for storing JSON in a fixed-width column or cache key, and for shrinking a JavaScript or configuration payload before it is shipped to a browser.
How to minify JSON
Paste your formatted JSON into the input panel, press the Minify JSON button, then copy the result. There is nothing to install and no account to create, and the whole operation happens in your browser.
The same result is also what you would get from JSON.stringify(JSON.parse(input)) in JavaScript. This tool does the equivalent work with a JSON-aware scanner instead, which additionally preserves the exact text of string values, escape sequences and number literals.
JSON before and after
The example below starts as indented, multi-line JSON. After minification it is a single line with no space between any two tokens:
{
"user": {
"name": "John Doe",
"email": "john@example.com"
},
"items": [1, 2, 3],
"message": "Hello World",
"enabled": true
}{"user":{"name":"John Doe","email":"john@example.com"},"items":[1,2,3],"message":"Hello World","enabled":true}JSON without spaces
When people search for a way to remove spaces from JSON they usually mean the spacing that the formatter added between tokens, not the spaces inside their text. A minifier removes only the first kind.
This matters because a blank regex such as stripping every whitespace character would also collapse the contents of your strings. "Hello World" would silently become "HelloWorld", and a description or a sentence would lose every word boundary. A tool that removes whitespace from JSON is therefore only trustworthy if it knows which whitespace is significant.
This minifier reads the JSON as a token stream, so whitespace between tokens is discarded while everything inside a quoted string is copied through byte for byte.
The same rule applies to tabs and newlines written inside a string as escape sequences: they are part of the value, so they survive minification unchanged.
JSON on a single line
Formatted JSON spans many lines because indentation is added for readability. Minification produces JSON single line output: the entire document on one line, with no trailing newline and no line breaks between entries.
This is the form you want when the JSON has to fit somewhere that does not allow new lines, such as a URL query parameter, a shell argument, an HTTP header, a log line, or a single-line configuration value. It is also the form that compresses best over the wire before gzip or Brotli is applied.
JSON minifier vs JSON formatter
The two tools do opposite jobs and neither one changes your data.
| Aspect | JSON Minifier | JSON Formatter |
|---|---|---|
| Smallest possible output | Removes all insignificant whitespace | Adds indentation and line breaks |
| Typical result | One long line | Indented, multi-line block |
| Best for | Network payloads, URLs, caching, storage | Reading, reviewing, debugging, diffing |
| Data changes | None | None |
| Direction | Pretty JSON to compact JSON | Compact JSON to pretty JSON |
Frequently Asked Questions
What is JSON minification?
JSON minification is the process of rewriting a JSON document in its shortest equivalent form. It removes the whitespace that exists only for human readability - indentation, spaces between tokens, tabs and line breaks - so a pretty-printed JSON file becomes a compact single line. The data itself does not change, and the result is still perfectly valid JSON that any parser reads identically.
How do I remove spaces from JSON?
Paste your JSON into the input box above and press Minify JSON. The tool removes every space, tab and newline that sits between JSON tokens, which is what people usually mean when they ask how to remove spaces from JSON. Spaces inside string values are part of your data, so they are always kept - a value like "Hello World" stays "Hello World".
How do I convert JSON to a single line?
Use the Minify button above. Formatted or multi-line JSON is collapsed into one line with no unnecessary whitespace, which is the usual way to turn JSON into a single line for a URL, a command line argument, a log entry or a configuration value. Copy the result with the Copy button when you are done.
Does JSON minification remove spaces inside strings?
No. A minifier only removes insignificant whitespace that sits between JSON tokens. Anything inside a quoted string - spaces, tabs written as escape sequences, punctuation - is data and is preserved exactly. So {"message": "Hello World"} becomes {"message":"Hello World"} and never {"message":"HelloWorld"}. This is also why a naive search-and-replace of all whitespace, such as replacing every space with nothing, is unsafe: it corrupts your string values.
Is minified JSON valid JSON?
Yes. Minified JSON is the same document with insignificant whitespace removed, so it is valid JSON by definition. The only difference is that it is hard for a human to read. If you want the readability back, run it through the JSON Formatter, which reverses the process without touching the data.
Can I minify large JSON files?
Yes. Minification runs entirely in your browser, so there is no upload size limit and nothing is sent to a server. Large API responses and multi-megabyte data files are processed locally, which also keeps your data private.
What is the difference between JSON minify and JSON beautify?
They are opposite operations. JSON minify, also called JSON compression, makes JSON as small as possible by removing whitespace, which is useful for transfer size and embedding in URLs or code. JSON beautify, also called JSON format or pretty print, does the opposite: it takes compact JSON and adds indentation and line breaks so a person can read it. Neither operation changes the data, so you can round-trip between them without loss.
What happens if my JSON is invalid?
No output is produced. The minifier validates your input first, and if the JSON is malformed it reports the problem with the approximate line, column and character position, for example a trailing comma before a closing brace or an unquoted key. That way an invalid document can never be mistaken for a minified result.