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, rather than uploading the pasted JSON for formatting.
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 removing unnecessary whitespace outside strings. 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
The tool’s parser tracks where each token starts. When it finds an error, it shows the line and column, an excerpt with a caret under the relevant character, and an explanation such as A comma between two properties is probably missing. Use Jump to error to move the cursor to that position in the input.
Common syntax problems include:
| 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
A JSON.parse / JSON.stringify round trip can alter large numbers and their written representation. 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. To make two API responses easier to compare, enable Sort keys to list object properties alphabetically at every level. This is a display-order option, not a cryptographic JSON canonicalisation scheme.
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.
Minification removes unnecessary whitespace outside strings. It can reduce JSON sent to a browser, stored in a database or embedded in an HTML attribute. The reduction depends on the document; any further benefit after Gzip compression also varies. Check the size readout for your own input.
Working with JSON in the terminal and in editors
For files you process repeatedly, a command-line tool can fit an automated workflow. jq . file.json pretty prints, jq -c . file.json minifies, and python -m json.tool file.json works wherever Python is installed. Editors can also provide formatting and schema validation. This tool checks JSON syntax; it does not check an application-specific schema. 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 epoch timestamps into readable dates when the field uses that format, and the UUID decoder checks UUID versions and, where encoded, their timestamp fields. More utilities are listed under developer tools.
Frequently asked questions
Is my JSON uploaded to a server?
No. Parsing, formatting and repair run in your browser. Once the page has loaded, these functions can work without a network connection. The tool does not send the pasted JSON to our server or save it in browser storage.Why does the validator reject comments when my editor accepts them?
Standard JSON does not allow comments. 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 can strip comments, but other syntax errors may still need attention. Check the repaired result.
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?
Usable document size and processing time depend on browser memory, nesting depth and device performance. Syntax highlighting is disabled for large input to reduce rendering work; formatting, copying and downloading still depend on available resources.Does sorting keys change the data?
Object member order is not significant in the JSON data model; array order is preserved. Sorting still changes the document bytes and can affect signatures, hashes or software that relies on property order. Treat documents with duplicate keys cautiously because receiving parsers can interpret them differently.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.
Compare two consistently formatted documents with the text diff checker.