Runs in your browser. Your files and text never leave your device - nothing is uploaded.
Format, Minify, and Validate JSON
This free JSON formatter turns a dense, single-line payload into readable, indented JSON, or squeezes indented JSON back down to one line. Every time you click Format / Beautify or Minify, the input is parsed first, so the same click also works as a JSON validator: valid JSON comes out formatted, and invalid JSON produces the parser’s error message instead.
Everything runs in your browser using its built-in JSON parser. Nothing you paste is uploaded, which matters when the payload contains API keys, customer records, or internal responses. It is one of several free developer tools on this site that work the same way.
How to Use the JSON Formatter
- 1
Paste your JSON
Paste or type raw JSON into the "Raw JSON" box. It can be minified, messy, or already indented.
- 2
Pick an indent size
Choose 2, 4 or 8 spaces from the Indent dropdown. The setting applies to Format / Beautify.
- 3
Format or minify
Click "Format / Beautify" to pretty-print the JSON, or "Minify" to collapse it onto a single line. If the JSON is invalid, an error message from the parser appears instead.
- 4
Copy the result
Click Copy under the output panel to put the result on your clipboard, or Clear to start again.
No account is needed, and there is no daily limit.
Beautify vs. Minify: What Changes
Take the sample object the tool starts with. Minified, it is 56 characters on a single line:
{"name":"Alice","age":30,"hobbies":["coding","reading"]}Formatted with a 2-space indent, it becomes 82 characters over nine lines:
{
"name": "Alice",
"age": 30,
"hobbies": [
"coding",
"reading"
]
}With a 4-space indent the same object is 98 characters, and with 8 spaces it is 130. The data is identical in every version; only whitespace changes. Beautified JSON is for reading, reviewing and diffing. Minified JSON is for sending over a network, embedding in an environment variable, or storing where size matters. For HTML, CSS or JavaScript rather than JSON, use the code beautifier.
Common JSON Syntax Errors and How to Fix Them
JSON is stricter than the JavaScript object syntax it resembles. These are the mistakes that most often make a payload fail to parse:
- Trailing comma —
{"a": 1,}is invalid. Delete the comma after the last item in an object or array. - Single quotes —
{'a': 1}is invalid. Keys and strings must use double quotes. - Unquoted keys —
{a: 1}is invalid. Every key must be a double-quoted string. - Comments —
//and/* */are not part of JSON. Remove them before parsing. - Missing bracket or brace — an unclosed
[or{is reported at the very end of the input, because the parser runs out of text while still expecting a comma or closing bracket.
In Chrome and Edge the error message includes the character position plus a line and column, such as “at position 7 (line 1 column 8)”, which points you straight at the problem. Other browsers word the message differently. The tool does not rewrite your input, so fix the character it points to and click Format again. If a value looks like gibberish, it may be Base64; the Base64 decoder reveals what is inside, and the JWT decoder splits a token into its JSON header and payload.
What a Parse-and-Format Round Trip Normalizes
The formatter reads your text into data and writes that data back out, so a few details can differ from the original even though the JSON is equivalent:
- Duplicate keys — only the last value is kept, so
{"a":1,"a":2}becomes{"a":2}. - Very large integers — numbers above 9,007,199,254,740,991 lose precision; 12345678901234567890 comes back as 12345678901234567000. Store long IDs as strings.
- Number formatting — 1.50 becomes 1.5 and 1e3 becomes 1000.
- Unicode escapes —
"\u00e9"is written out as"é".
If you need to confirm exactly what changed between two versions of a file, paste both into the text compare tool after formatting them with the same indent.
Converting JSON to Other Formats
Once your JSON is valid, you can take it further. Turn an array of objects into a spreadsheet with the JSON to CSV converter, produce markup for an older integration with JSON to XML, or switch a config file between formats with the YAML to JSON converter, which works in both directions. Working with XML instead? The XML formatter pretty-prints and validates it the same way this tool handles JSON.
Common uses
- Reading an API response that arrived as one long line
- Checking a webhook payload or request body for syntax errors before sending it
- Tidying package.json, tsconfig.json or app settings before a commit
- Minifying JSON to fit in an environment variable or a single log line
- Matching a project’s indentation style of 2, 4 or 8 spaces
JSON formatter terms explained
| Term | What it means here |
|---|---|
| Beautify / pretty-print | Re-writing JSON with line breaks and indentation so each key and array item sits on its own line |
| Minify | Removing every optional space and line break so the JSON takes up as few characters as possible |
| Validate | Checking that text is well-formed JSON; here it happens every time you click Format or Minify |
| Object | A set of "key": value pairs wrapped in curly braces { } |
| Array | An ordered list of values wrapped in square brackets [ ] |
| Parse error | The message the browser’s JSON parser returns when the text breaks JSON syntax |
Frequently Asked Questions
Paste the JSON into the Raw JSON box, choose an indent of 2, 4 or 8 spaces, and click Format / Beautify. The pretty-printed version appears in the output panel, ready to copy.
Yes. The input is parsed with the browser’s built-in JSON parser before it is formatted or minified. If it is not valid JSON, you see "Invalid JSON:" followed by the parser’s error message instead of output.
It shows the error message your browser’s JSON parser produces. Chrome and Edge include the character position plus the line and column, for example "at position 7 (line 1 column 8)"; other browsers word the message differently and may give less detail.
The usual causes are a trailing comma after the last item, single quotes instead of double quotes, unquoted keys, comments, or a missing closing bracket or brace. JSON allows none of these, even though JavaScript object literals allow most of them.
Beautify adds line breaks and indentation so a person can read the structure. Minify removes all optional whitespace so the JSON is as short as possible for sending or storing. Both produce the same data.
Two, four or eight spaces. Two spaces is the common default in JavaScript and web projects, four is common in Python and Java codebases. Tabs are not offered.
No. It does not guess at repairs. It reports the parser error so you can make the fix yourself, then click Format again to confirm the JSON is valid.
The structure and values stay the same, but a parse-and-rewrite round trip normalizes some things: duplicate keys keep only the last value, integers larger than 9,007,199,254,740,991 lose precision, 1.50 becomes 1.5, 1e3 becomes 1000, and escapes like \u00e9 are written as the character itself.
No. Parsing, formatting and minifying all happen in your browser with JavaScript. Nothing you paste is sent to or stored on a server.
No. It accepts standard JSON only, so comments, trailing commas, single-quoted strings and unquoted keys are reported as errors.
Reviewed by Raja Jahangir · Last reviewed: October 7, 2026
How do you format and validate JSON?
To format JSON, paste it and the structure is re-indented with consistent nesting so it can be read. Invalid JSON is rejected with the JSON parser error message - the usual causes are a trailing comma, a single quote, or an unquoted key. Formatting runs in your browser.
