Overview
A JSON minifier turns formatted JSON into a compact string by stripping unnecessary spaces, tabs, and line breaks. The data stays the same, but the payload becomes smaller and easier to embed in code, send in requests, or store in logs. Use it when you need a condensed representation for APIs, configuration snippets, fixtures, or debugging exports. If the input is not valid JSON, the tool cannot safely minify it, so fix syntax issues such as trailing commas, missing quotes, or unmatched brackets first. The output is meant to be machine-friendly, not easy to read. If you need a human-readable layout again, use a JSON formatter after minifying or whenever you want to inspect the structure.
Use cases
- Trim API payloads before sendingCondense a request body that was formatted for review so it can be embedded in tests or shared as a single-line payload.
- Store sample fixtures in a compact formKeep example responses or test data small when you want them committed in a compact representation.
- Prepare config snippets for transportReduce line breaks and indentation before pasting JSON into another system or environment variable.
How it works
- 1
Paste valid JSON into the input field.
- 2
The tool removes non-essential whitespace while preserving values and nesting.
- 3
Copy the compact result for code, transfer, or storage.
Examples
Pretty JSON to compact string
Input: { "user": "alex", "roles": [ "admin", "editor" ], "active": true }
Output: {"user":"alex","roles":["admin","editor"],"active":true}
Whitespace is removed, but arrays, booleans, and object structure remain unchanged.
Nested object with numbers
Input: { "order": { "id": 1042, "items": [ { "sku": "A1", "qty": 2 }, { "sku": "B7", "qty": 1 } ] } }
Output: {"order":{"id":1042,"items":[{"sku":"A1","qty":2},{"sku":"B7","qty":1}]}}
Nested objects and arrays are compressed into a single line without changing values.
String values containing punctuation
Input: { "message": "Save, then retry.", "note": "Spacing inside strings stays as typed." }
Output: {"message":"Save, then retry.","note":"Spacing inside strings stays as typed."}
Spaces inside quoted strings are preserved because they are part of the data, not formatting.
FAQ
Will the minifier change numbers, booleans, or string values?
No. A correct minifier removes only formatting whitespace outside JSON strings. The values themselves should stay exactly the same.
What happens if the input is not valid JSON?
The tool should not produce a safe compact result from broken syntax. Fix issues such as trailing commas, missing quotes around keys, or unmatched braces first.
Are spaces inside quoted text removed?
No. Spaces inside strings are part of the JSON value and must remain unchanged. Only formatting spaces outside strings are removed.
Can I minify JSON that contains escaped characters or Unicode?
Yes, as long as the JSON is valid. Escapes such as \n, \t, \\, and Unicode characters remain encoded according to the input data.
