Help

JSON Formatter Online: Pretty-Print and Validate JSON

Paste raw or minified JSON and get it back indented, colour-coded and checked. Big numbers, key order and duplicate keys come out exactly as you wrote them, and if the JSON is broken you see what is wrong and the line and column where it happens.

How to format JSON online

  1. Paste your JSON into the Raw JSON box (it says Paste raw JSON here...). A paste is formatted at once. When you type, the result updates about 300 milliseconds after you stop.
  2. Read the result in Formatted JSON. Keys, strings, numbers, true/false and null each get their own colour. Long lines scroll sideways instead of wrapping, so the indentation stays readable.
  3. When the JSON is valid, Valid JSON. appears under the result. If not, a red Invalid JSON box explains why (see below).
  4. Select Copy in the heading of the result. The button reads Copied for a moment, and what you paste is the plain text without colours.
  5. Select Clear at the bottom to empty the box and start again.

Pretty print JSON with 2 spaces, 4 spaces or tabs

Select the gear icon next to the title to open Indentation. The choices are 2 spaces (the default), 4 spaces and Tab. The formatted JSON changes as soon as you choose, and the setting applies to the text you copy as well. Two spaces gives the shortest lines for deeply nested data; four spaces or tabs match the style guides of many projects.

Why numbers and key order stay exact

Most JSON formatters parse your text into an object and print it again. That round trip quietly rewrites data. This one reads your original text, checks it against the JSON rules, and changes only the whitespace between tokens. Everything else is copied character for character.

Here is the same input through this tool and through JSON.parse followed by JSON.stringify:

Input {"id":12345678901234567890,"price":1.0,"tag":"a","tag":"b","b":1,"2":3}
WhatThis toolJSON.parse + JSON.stringify
Large number1234567890123456789012345678901234567000 (rounded)
Decimal1.01
Duplicate keyboth "tag" entries keptonly the last value survives
Key order"b" before "2", as written"2" jumps to the front

This matters for database IDs, order numbers and prices copied from an API response: the formatted text is the same data as the original, only easier to read.

Fix invalid JSON: what the error messages mean

The tool checks strict JSON (RFC 8259). When the text does not pass, the Invalid JSON box gives a plain-language reason and Line N, column M for the first problem it finds. Typical cases:

MistakeExampleWhat the box says
Trailing comma[1, 2,]There is a comma right before a closing bracket. JSON does not allow a trailing comma.
Single quotes{'name': 'Ana'}JSON uses double quotes, not single quotes. Replace this one with ".
Comment// noteJSON does not allow comments.
Unquoted property name{name: "Ana"}A property name in double quotes is expected here, but this is “n”.
Missing comma"b": 2 "c": 3A comma or a closing bracket is expected here, but this is “"”.
Leading zero or 1.01This is not a valid JSON number.
NaN, undefined or another bare word{"a": undefined}Only true, false and null can appear without quotes. Put other words in double quotes.
Text after the JSON{"a": 1}}There is extra text after the end of the JSON, starting with “}”.
Line break inside a stringa string split over two linesA line break or control character sits inside this string. Write it as an escape such as \n.

The same box covers a string that is never closed, a bad backslash escape and a bracket that is still open at the end of the text (The text ends too early). A non-breaking space pasted from a web page or a chat shows up as U+00A0 so you can find and delete it, and a byte-order mark at the very start of a file is ignored.

A multi-line example shows the position. In this text the second line is missing its comma:

Input {"a": 1,
"b": 2
"c": 3}

The box reports Line 3, column 2, the opening quote of "c", which is where a comma should have come before it.

Limits and what this tool does not do

Frequently asked questions

How do I format JSON online?

Paste your JSON into the Raw JSON box. It is formatted at once on paste, or about 300 milliseconds after you stop typing, and the indented result appears in Formatted JSON below it. Select Copy to take it with you. The formatting happens in your browser, so the JSON is never uploaded.

How do I pretty print JSON with 4 spaces or tabs?

Select the gear icon next to the title to open the Indentation menu and choose 2 spaces, 4 spaces or Tab. The default is 2 spaces, and the result changes the moment you pick another option.

How do I check if my JSON is valid?

Paste it. A valid document is formatted and a Valid JSON. line appears under the result. An invalid one shows a red Invalid JSON box with the reason in plain language and the Line and column where the problem is.

Why does my JSON have a trailing comma error?

JSON does not allow a comma after the last item of an object or array, such as [1, 2,]. The tool points at the closing bracket that follows the stray comma. Delete the comma and the JSON formats.

Can JSON have comments?

No. Strict JSON (RFC 8259) has no comment syntax, so // and /* */ are errors even though some config files tolerate them. The tool reports JSON does not allow comments at the exact line and column, and you remove the comment to continue.

Why does my JSON fail with single quotes or unquoted keys?

JSON requires double quotes around every string and every property name. {'name': 'Ana'} and {name: "Ana"} are valid JavaScript but not valid JSON, so the tool stops at the first offending character and tells you which quote or name to fix.

What does JSON parse error unexpected token mean?

It means the parser met a character it did not expect at that spot. This tool names the character it found, says what it expected instead, for example a comma or a closing bracket, and gives the line and column, which is usually enough to see the typo.

Does formatting change my numbers or key order?

No. The tool checks your original text and only rewrites the whitespace between tokens. Numbers, strings, key order and duplicate keys are copied exactly, so 12345678901234567890 is not rounded and 1.0 stays 1.0. JSON.parse followed by JSON.stringify changes all of these.

Can it format large JSON files?

Yes, up to 5,000,000 characters and 1000 levels of nesting. The formatting itself takes a fraction of a second, but showing a multi-megabyte result can take a few seconds. Above 800,000 characters the result is shown without syntax colours to stay fast, and Copy still works.

Is my JSON uploaded anywhere?

No. The JSON is formatted entirely on your device and nothing is uploaded or saved.

Can it minify JSON, sort keys or convert it to YAML or CSV?

No. This tool only pretty-prints and validates. It keeps your keys in their original order, and it does not minify or convert.

What is the difference between a JSON formatter, beautifier and validator?

A formatter and a beautifier both add line breaks and indentation so JSON is easy to read. A validator checks that the text is legal JSON. This tool does both in one step: it validates strictly and, when the JSON is valid, it formats it.

Recommended

Helps keep the tools free. ✨

Images are for illustration only. As an Amazon Associate I earn from qualifying purchases.