JSON formatter and validator

Paste JSON to format it with 2 spaces, 4 spaces or tabs, or to minify it onto one line. The tool checks it as you type. If the JSON is invalid, it shows the error with its line and column and points to the spot. You can also sort keys, copy the result or download it.

Free, no sign-up Runs in your browser

How to format, minify or validate JSON

  1. Paste your JSON into the input box, or click Load example.
  2. Choose Format or Minify. Format adds line breaks and indentation so you can read it. Minify removes every space and line break that isn't inside a string.
  3. Pick the indentation (2 spaces, 4 spaces or a tab) and whether to sort keys.
  4. Read the status bar. Green means the JSON is valid. Otherwise you see the error, the line and column, and the line itself with a ^ under the problem.
  5. Copy or download the result.

The tool waits until you pause typing before it checks, so it stays responsive with large files. Everything runs in your browser, which makes it safe for API responses that contain tokens or customer data.

Worked example

This minified input:

{"name":"Asha Rao","skills":["UI","branding"],"rate":{"amount":45,"currency":"USD"}}

formatted with 2 spaces becomes:

{
  "name": "Asha Rao",
  "skills": [
    "UI",
    "branding"
  ],
  "rate": {
    "amount": 45,
    "currency": "USD"
  }
}

Formatting and minifying change only the whitespace between values. The data stays the same.

Common JSON errors and how to fix them

ProblemInvalidValid
Trailing comma{"a": 1,}{"a": 1}
Single quotes{'a': 'x'}{"a": "x"}
Key without quotes{a: 1}{"a": 1}
Missing comma{"a": 1 "b": 2}{"a": 1, "b": 2}
Comments{"a": 1} // note{"a": 1}
JavaScript-only values[NaN, undefined][null, null]
Leading zero{"id": 007}{"id": 7} or {"id": "007"}

The reported position is where the parser noticed the problem, which is often just after the real mistake. A missing comma, for example, is reported at the start of the next key. Look at the end of the previous line too.

Indentation and sorted keys

Two spaces is the most common style for JSON on the web. Four spaces is the default of Python's json.tool module. Tabs keep files a little smaller and let each reader choose the width in their editor.

Sort keys puts the keys of every object in alphabetical order, at every level. The JSON standard (RFC 8259) treats an object as unordered, so sorting doesn't change the meaning. It makes two versions of a file much easier to compare. Arrays keep their order, because order matters in an array.

Limits to know about

  • Very large numbers: browsers store numbers as 64-bit floating point. Integers above 9,007,199,254,740,991 (253 − 1) lose precision, so 12345678901234567890 is shown as 12345678901234567000. If your IDs are that long, store them as strings.
  • Duplicate keys: if an object repeats a key, only the last value is kept.
  • File size: files of several megabytes are fine. The real limit is your device's memory.

Frequently asked questions

Is my JSON sent to a server?
No. Parsing, formatting and validation all run in your browser with JavaScript. Nothing you paste leaves your device, and the JSON itself isn't saved; only your format settings are remembered.
What does "Unexpected token" mean?
The parser found a character it didn't expect at that point, such as a single quote, a comment, a trailing comma or an unquoted key. Check the line and column shown, and the end of the line before it.
Can JSON have comments?
No. Standard JSON has no comments. Some tools accept variants such as JSONC or JSON5 that allow them, but a standard parser will reject the file. Remove the comments, or move notes into a field such as "_comment".
What is the difference between JSON and a JavaScript object?
JSON is a text format with stricter rules: keys must be in double quotes, strings use double quotes, and there are no comments, trailing commas, functions or undefined.
How do I minify JSON?
Paste it, choose Minify, then copy or download the result. Minifying removes spaces and line breaks outside strings, which makes the file smaller without changing the data.

Last updated . How we check our tools.