JSON Minifier

Minify JSON to a single compact line

Strips whitespace and newlines from JSON to produce a compact single-line output. Useful when you need to embed JSON in a config file, a URL parameter, or an environment variable where multi-line strings cause problems.

Input
Output
Minified JSON will appear here…

How to use

  1. 1Paste JSONFormatted JSON with indents and line breaks.
  2. 2Get resultsIn auto mode, JSON is minified instantly on paste. Disable auto mode to run manually with Run.
  3. 3Copy the resultReady to paste into an environment variable, URL parameter, or config.

Examples

JSON for an environment variable
{"db":{"host":"localhost","port":5432}}
Convert JSON to single-line format — environment variables don't support multi-line values.
POST request body
{"query":"SELECT * FROM users","limit":100}
Prepare a compact body for a POST request — strip extra whitespace before sending.
Embedding in an HTML data attribute
{"id":42,"type":"product"}
Compress JSON for a data attribute — the attribute can't contain line breaks.
Nested API response structure
{"a":1,"b":{"c":[1,2,3]}}
Minify a nested structure and compare as a string — useful for deduplicating API responses.
Array of objects from an API
[{"id":1,"name":"Alice"},{"id":2,"name":"Bob"}]
Compress an array before passing to a URL parameter or computing a hash — get a stable string.

When to use for web scraping

In scraping, JSON minification is needed less often than formatting — but a few scenarios come up: passing a config in CI/CD environment variables, embedding JSON in HTML data attributes, forming a compact POST request body for APIs with size limits. Also useful for comparison: if two JSONs look different due to formatting, minify both and compare the strings — if they match, the data is identical.

FAQ

Is data lost during minification?
No. Only formatting whitespace and line breaks are removed. Structure, keys, and values remain unchanged.
What's the difference from JSON Beautifier?
These are opposite operations. Beautifier adds readability, Minifier removes it. The data is the same — just different size and readability.
How does minification affect parser performance?
Minified JSON is smaller — less traffic and faster transfer. However, it has almost no impact on parsing speed (deserialization): parsers work on a stream of characters and don't depend on indentation.
Is it safe to minify JSON with floating-point numbers?
Yes. The minifier doesn't change number values — it only removes whitespace characters. Numbers like 3.14159 or 1e-10 are preserved exactly as-is.
Can I minify invalid JSON?
No. Minification requires valid JSON. If the structure is broken (trailing comma, unclosed bracket), the tool returns an error. Use JSON Beautifier to first identify and fix errors.

Related tools