JSON Formatter and Minifier
Paste JSON to validate it and print it neatly, or compress it to a single line.
INPUT
CHARS: 0WORDS: 0LINES: 0
OUTPUT
CHARS: 0WORDS: 0LINES: 0
How the JSON Formatter and Minifier works
The input is parsed with the same strict parser used by browsers and JavaScript runtimes, so a pass here means other tools will accept the JSON too. Beautify mode indents with two spaces, four spaces or tabs. Minify mode removes every optional space and line break.
When the JSON is invalid, the tool reports the problem with its line and column, such as an unexpected token or a missing comma. Sorting keys alphabetically at every level makes it easy to compare two documents or keep files diff friendly.
JSON Formatter and Minifier examples
Sample input with the default options
Input
{"name":"Ada","skills":["math","code"],"active":true}Result
{ "name": "Ada", "skills": [ "math", "code" ], "active": true }
When it is useful
- •Making an API response readable.
- •Finding the missing comma or stray quote in a config file.
- •Minifying JSON before embedding it in a request or a script.
- •Normalizing key order before comparing two JSON files.
Frequently Asked Questions
Why is my JSON invalid when it looks fine?
Common causes are trailing commas, single quotes around strings, unquoted keys and comments. JSON is stricter than JavaScript object syntax.
Does sorting keys change the meaning?
No. JSON objects are unordered. Array order is never changed.
How large a file can it handle?
Files of several megabytes work fine on a modern computer, since everything is processed locally.
Guides that use this tool
Related tools
- JSON to YAML ConverterSwitch configuration between JSON and YAML in either direction.
- JSON Stringify TextPaste text, get a string literal that is safe to place inside JSON.
- JSON UnstringifierPaste a string full of backslashes and see the original content.
- CSV to JSON ConverterPaste CSV and get an array of JSON objects, or an array of arrays if there is no header.
- XML FormatterPaste XML to check it and lay it out with clear indentation.
- JSON Key Case ConverterRename every key in nested JSON in one pass, leaving the values alone.