JSON Formatter and Validator
Paste any JSON into the field above and this JSON formatter and validator checks it as you type. Valid input is pretty printed with the indent you choose, or minified into a single line. Invalid input gets a precise error with the line and column, a highlighted snippet and, for the usual mistakes, a one-click fix. Everything runs in your browser, so API responses, configuration files and exports never leave your computer.
What this JSON formatter does
- Beautify JSON with 2 spaces, 4 spaces or tabs. The output keeps the original key order unless you tick Sort keys.
- Minify JSON by stripping every space and line break. The size readout under the result shows how many bytes you saved.
- Validate JSON live against RFC 8259, the current JSON standard. The status line turns green the moment the document is correct.
- Fix common errors automatically: trailing commas, single quotes, unquoted keys, comments, Python style
True,NoneandNaN, numbers like.5or+1. - Load files with the Open file button or by dropping a
.jsonfile onto the input, then download the result or send it back into the input for another pass.
Why the error message matters more than the red color
Most online validators only say that something is wrong. Browsers are not much better: JSON.parse in Chrome reports Unexpected token } in JSON at position 148, while Firefox says expected property name or '}', and neither tells you which line to look at. This tool has its own parser that remembers where every token starts. When it stops, you get the line and column, an excerpt of that line with a caret under the offending character, and a plain language hint such as A comma between two properties is probably missing. The Jump to error button moves the cursor straight to that position in the input.
The most frequent mistakes we see in pasted documents:
| Input | Problem | Correct JSON |
|---|---|---|
{'name': 'Ada'} | single quotes | {"name": "Ada"} |
{name: "Ada"} | unquoted key | {"name": "Ada"} |
[1, 2, 3,] | trailing comma | [1, 2, 3] |
{"a": 1 "b": 2} | missing comma | {"a": 1, "b": 2} |
{"ok": True} | Python literal | {"ok": true} |
{"x": 007} | leading zero | {"x": 7} or {"x": "007"} |
// comment | comment | not allowed in JSON |
The Fix it for me button repairs all of these except the missing comma and the leading zero. The fix is deliberately conservative: it never guesses where a missing comma belongs, because inserting one in the wrong place changes the meaning of the data, and 007 could be meant as the number 7 or as a code. In those cases you get the exact position instead.
Large numbers, key order and other things that usually break
Many formatters work by calling JSON.parse and then JSON.stringify. That round trip silently damages data. A Twitter or Snowflake ID such as 1234567890123456789 exceeds the 2^53 limit of JavaScript numbers and comes back as 1234567890123456800. The value 1.0 turns into 1, and 1e3 into 1000. This formatter never converts numbers to floating point. It copies every literal exactly as it was written, so the output is a faithful reformatting of the input, not a reinterpretation of it. The same applies to escape sequences inside strings: "\u00e9" stays "\u00e9" and is not turned into "é".
Key order is also preserved. The JSON specification says object members are unordered, but configuration files, test fixtures and code reviews read much better when the order is stable. If you prefer a canonical form, for example to compare two API responses in a diff tool, enable Sort keys and both documents will list their properties alphabetically at every nesting level.
Format JSON vs minify JSON: when to use which
Pretty printed JSON is for people. Use it when you review an API response, write a package.json, tsconfig.json or an OpenAPI document, or when you store fixtures in a repository where diffs should show one change per line. Two spaces is the convention in the JavaScript world, four spaces is common in Python and .NET projects, and tabs let every reader pick their own width.
Minified JSON is for machines. Whitespace typically makes up 20 to 40 percent of a formatted document, so removing it shrinks payloads sent to browsers, values stored in Redis or a database column, and data-* attributes embedded in HTML. Gzip closes part of that gap, but the minified version still compresses to a smaller result. The size readout under the result shows the exact difference for your document.
Working with JSON in the terminal and in editors
For files you process repeatedly, a command line tool is faster than any website. jq . file.json pretty prints, jq -c . file.json minifies, and python -m json.tool file.json works wherever Python is installed. Visual Studio Code formats JSON with Shift+Alt+F and validates it against a schema when you add a $schema property. This page is for the other cases: a response copied from the network tab, a log line, a configuration snippet from a wiki, or a quick check on a machine where you cannot install anything.
Related tools on this site: the Base64 encoder and decoder decodes the payload part of a JWT, which is JSON encoded in Base64url. The Unix timestamp converter turns the createdAt numbers found in most API responses into readable dates, and the UUID decoder tells you the version and timestamp of identifiers in your data. More utilities are listed under developer tools.
Frequently asked questions
Is my JSON uploaded to a server?
No. Parsing, formatting and repair run entirely in your browser in JavaScript. Once the page has loaded you can switch off the network and the tool keeps working. Nothing is logged or stored.Why does the validator reject comments when my editor accepts them?
Comments were removed from JSON on purpose by its author, Douglas Crockford, to prevent the format from being used for parser directives. Files liketsconfig.json or .vscode/settings.json are technically JSONC, a superset that editors support. Strict parsers in APIs, databases and most programming languages reject them. The fix button strips comments so the result is valid everywhere.
Can I format JSON Lines or several objects at once?
A JSON document holds exactly one value. If you paste several objects separated by commas or line breaks, the validator stops at the first extra value. Wrap them in square brackets to make an array, then format. The fix button does not do this automatically because it cannot know whether the input was meant to be one document.What is the maximum size?
There is no fixed limit. Documents of a few megabytes format in well under a second on a laptop. Syntax highlighting is switched off above roughly 400 kB to keep the page responsive, but copying and downloading still work.Does sorting keys change the data?
No. Objects in JSON are unordered by definition, see the JSON article on Wikipedia, so a parser reads the sorted and the original document as the same value. Arrays are never reordered because their order is part of the data.How do I escape JSON for embedding in a string?
Minify first, then escape every backslash and double quote. Many languages provide this directly:JSON.stringify(JSON.stringify(obj)) in JavaScript or json.dumps(json.dumps(obj)) in Python produce a JSON string containing the JSON text.