Minify and Validate JSON
Start with a small inventory object and choose Format JSON. Minify mode removes formatting whitespace after validating the document.
The example becomes {"label":"Desk lamp","counts":[2,5],"active":true}. The space in “Desk lamp” stays inside the value.
Your result
Worked example
Minification removes indentation, line breaks and spaces between JSON tokens. A space inside a quoted string is part of its data and stays. The objects, arrays, numbers and Boolean values keep their roles in the compact version.
Paste the exact JSON you intend to use and run the tool. If the document fails validation, check the reported syntax error. Common issues include an extra comma at the end of an array, missing closing braces and single quotes around a property name.
Compact JSON is convenient when you want a smaller payload or fixture. Use Pretty print for code review or troubleshooting so nested keys and arrays are easier to scan. Syntax validation checks whether the document parses as JSON. A receiving API may still require specific fields, types or an application schema.
To test a common mistake, add a comma after the final true value before the closing brace. Validation should fail until you remove it. That quick test helps distinguish a syntax error from an unexpected field value.
Questions about this example
Why does the space in “Desk lamp” survive minification?
Minification only removes whitespace between JSON tokens, such as indentation, line breaks and spaces after colons or commas. A space inside a quoted string is part of the value's data, so removing it would change the content. Objects, arrays, numbers and Boolean values all keep their roles in the compact output.
What are common reasons a document fails validation?
Frequent causes are a trailing comma after the last item in an array or object, a missing closing brace, and single quotes around a property name. To try it, add a comma after the final true value in the example; validation should fail until you remove it, which separates syntax errors from unexpected values.
If my JSON passes validation, will an API accept it?
Not necessarily. Syntax validation only confirms the document parses as JSON. A receiving API may still require particular fields, value types or an application schema the validator does not check. Compact output suits payloads or fixtures, while Pretty print makes nested keys and arrays easier to scan when reviewing or troubleshooting a rejected request.
For other inputs and methods, open the JSON Formatter & Validator.