JSON Formatter
Format, beautify and minify JSON with instant validation — all in your browser.
- Free forever
- No sign-up
- Runs in your browser
JSON input
Output
Your formatted JSON will appear here.What is a JSON formatter?
JSON (JavaScript Object Notation) is the most common way to exchange structured data between apps, APIs and config files. It is compact and machine-friendly, but a minified payload on a single line is almost impossible for a human to read. A JSON formatter takes that raw text and reprints it with consistent indentation and line breaks, so the structure becomes obvious at a glance.
This tool does three jobs in one: it validates your JSON (telling you precisely where it breaks), beautifies it for reading, and minifies it for shipping. It runs entirely in your browser — there is no upload, no account and no network call — so it works offline and keeps your data private.
How to use it
- Paste your JSON into the input box. You can also click Sample to load a small example and see how it behaves.
- Click Format to pretty-print it with indentation, or Minify to collapse it to a single compact line.
- Choose your indent width with the 2 / 4 toggle. Two spaces is the common default; four is easier to scan for deeply nested data.
- If the JSON is invalid, a red error message appears under the input describing what went wrong.
- Click Copy to grab the output, or Clear to start over.
The output area uses a monospace font and preserves whitespace, so the indentation you see is exactly what gets copied.
What "valid JSON" actually requires
JSON looks forgiving but is stricter than the JavaScript object literals many people are used to. The rules that trip people up most often:
- Keys must be in double quotes.
{name: "x"}is invalid;{"name": "x"}is correct. - Strings use double quotes, never single.
'hello'is not valid JSON. - No trailing commas.
[1, 2, 3,]and{"a": 1,}both fail. - No comments.
//and/* */are not part of JSON, even though many editors allow them in config files. - Only specific value types are allowed: strings, numbers, booleans,
null, arrays and objects. Things likeundefined,NaNand functions are not.
When any of these is broken, the browser's parser throws an error and this tool surfaces the message directly, so you can jump to the problem instead of guessing.
Reading validation errors
The error text comes straight from the JavaScript engine, so it is precise but terse. A few common ones:
- "Unexpected token ... in JSON" — usually a stray character, a single quote, or a value that is not quoted.
- "Unexpected end of JSON input" — a bracket or brace was opened but never closed.
- "Expected property name or '}'" — often a trailing comma before a closing brace.
Some browsers also include a position or line number. Treat it as a starting point: the real mistake is sometimes a character or two earlier, such as a missing comma between two entries.
Format vs minify: when to use each
- Format / beautify is for humans. Use it when you are debugging an API response, reviewing a config file, or trying to understand the shape of unfamiliar data. Indented JSON makes nesting, arrays and missing fields jump out.
- Minify is for machines and transport. Removing every optional space shrinks the payload, which means faster transfers and smaller storage. The data is identical — only the whitespace changes — so a minified and a formatted version of the same JSON are completely equivalent.
A common workflow is to paste a minified blob, hit Format to inspect it, make sense of it, and then Minify it again before pasting it back where it belongs.
Tips for working with JSON
- Indent for diffs. If your JSON lives in version control, store it pretty-printed with a consistent indent so changes show up as small, readable diffs rather than one giant changed line.
- Validate before you ship. Running JSON through a formatter is a quick way to catch a typo that would otherwise fail silently at runtime or get rejected by an API.
- Watch number precision. Very large integers can lose precision once parsed, because JSON numbers are floating point. If you need exact big numbers, many systems encode them as strings.
- Keep keys consistent. Mixing
camelCaseandsnake_casekeys is valid JSON but a frequent source of bugs when code expects one and the data uses the other.
Common mistakes to avoid
- Copying JSON with surrounding text. Pasting a log line or a
data:prefix along with the JSON will break parsing. Paste only the JSON itself. - Treating a JavaScript object as JSON. Object literals from code often have unquoted keys, single quotes or trailing commas — all invalid here. Format catches these instantly.
- Assuming minify changes meaning. It does not. If a minified version behaves differently from a formatted one, the difference is somewhere else, not in the whitespace.
Private by design
Because parsing and formatting happen locally, you can safely paste tokens, internal API payloads or anything else sensitive. Nothing is transmitted, nothing is retained, and closing the tab clears it all. Need the same data in another shape? The JSON ↔ CSV Converter and JSON ↔ YAML Converter handle those conversions just as privately. Format what you need, copy the result, and move on.
Frequently asked questions
Comet's got your back
Stuck on something? Every tool has a short guide and FAQ — and Comet can point you to the right spot.
Visit help centreRelated tools
All Developer tools →Base64 Encoder / Decoder
Encode text to Base64 or decode it back — instantly and privately in your browser.
DeveloperURL Encoder / Decoder
Encode or decode URLs and query components instantly and privately in your browser.
DeveloperHash Generator
Generate SHA-1, SHA-256, SHA-384 and SHA-512 hashes of any text — privately in your browser.
Developer