JSON Formatter & Validator

Paste in JSON from an API, a config file, or a log, and get it back readable — or minified. If it is broken, the validator tells you exactly where.

Close-up of code in a dark editor, with line numbers and syntax highlighting
A code editor full of JSON — the formatter turns a one-line API response into indented, readable JSON.

Format your JSON

Result

Your formatted JSON will appear here.

What JSON is, and why it breaks so easily

JSON — JavaScript Object Notation — is the standard way APIs, config files, and web apps pass structured data around. It looks simple: curly braces for objects, square brackets for arrays, colons between keys and values, and commas between entries. A small object like {"name": "Ada", "active": true} is easy to read at a glance. The trouble starts when the data gets big. A real API response can run to hundreds of lines, and when it arrives minified — everything on one line — it is practically unreadable. That is the first job of a formatter: take the one-line blob and expand it with consistent indentation so the structure is visible again.

The second job is validation, and it matters more. JSON has strict rules, and a single small mistake makes the whole document invalid. Keys must be in double quotes — single quotes do not count. Strings must use double quotes too. There must be no comma after the last item in an object or array. Comments are not allowed, even though many config formats that look like JSON do allow them. And a value must be a string, a number, true, false, null, an object, or an array — nothing else. JavaScript values like undefined or a bare function are not valid JSON, which surprises people who copy a JavaScript object literal and expect it to parse.

When a parser hits one of these mistakes, it stops at the first error it finds and reports a position — a character offset, which this tool converts into a line and column number. That position is usually the most useful clue you will get. A trailing comma, for example, is reported at the closing brace, because that is where the parser expected another key and found the brace instead. The fix is almost always one character away from the reported position: delete the comma, add the missing quote, or remove the comment.

Minifying is the reverse operation. Once JSON is valid and readable, you may want it small again — for example, to paste into a URL parameter, store in a database field, or send over a network where every byte counts. Minifying strips all the whitespace that is not inside a string, leaving one compact line with the same data. Formatting and minifying never change the data itself: the keys, values, and nesting stay exactly the same, only the whitespace changes.

One warning is worth remembering. This tool, like every JSON parser, reads numbers as double-precision floating point, so a very large integer — longer than about 15 or 16 digits — may lose precision when it is reformatted. API keys, timestamps in milliseconds, and database IDs that large are usually safer as strings. If your data includes a 19-digit ID, check it after formatting. The full guide, How to Format JSON and Fix the Errors That Break It, walks through the five most common errors with examples of each.

Worked example

Valid input. Paste this compact object:

{"name":"Ada","role":"developer","skills":["JavaScript","Python"],"active":true}

Click Format JSON with 2-space indentation. The result is:

{ "name": "Ada", "role": "developer", "skills": [ "JavaScript", "Python" ], "active": true }

The tool reports: valid JSON, 4 top-level keys. Clicking Minify returns the original one-line form, byte for byte except for spacing.

Invalid input. Now paste this object, which has a trailing comma after "developer":

{ "name": "Ada", "role": "developer", }

The validator reports an error: it expected a double-quoted property name but found the closing brace — for the indented text above, at position 42, line 4, column 1, exactly where the closing brace sits. (The exact wording and position vary slightly by browser, but every parser points at that brace.) Delete the comma after "developer" and the document validates. That trailing comma is the single most common JSON error in the wild, usually left behind when a line is deleted from a hand-edited config file.

Frequently asked questions

Is my JSON sent to a server?

No. The formatting and validation run entirely in your browser with JavaScript. Nothing you paste is uploaded, stored, or shared. You can even use the tool offline once the page has loaded.

Why does JSON reject single quotes?

Because the JSON specification only allows double-quoted strings. JavaScript allows both, so an object literal copied from JavaScript code often fails. Replace single quotes with double quotes — carefully, so you do not change quotes inside the string values themselves.

Can I format JSON with comments in it?

Not as strict JSON — comments are not part of the JSON specification, so a parser rejects them. Formats like JSONC and JSON5 allow comments, but a plain JSON validator will flag them. Remove the comments, or use a JSONC-aware tool, if your file needs them.

What is the difference between formatting and minifying?

Formatting adds whitespace and line breaks so a human can read the structure. Minifying removes all unnecessary whitespace so the file is as small as possible. The data is identical either way; only the presentation changes.

Why did my large number change after formatting?

JSON numbers are parsed as double-precision floating point, which cannot represent integers longer than about 15–16 digits exactly. If you work with very large IDs, keep them as strings in quotes to preserve them exactly.

Note: This tool parses JSON in your browser using the standard JavaScript parser. It reports the first error it finds; fix that one, then validate again to find the next.

Related: Color Converter & Contrast Checker · Base64 & URL Encoder · How to format JSON and fix errors