JSON Formatter & Validator

Format, minify and validate JSON in your browser, with clear error messages that show the line and column.

Runs in your browser – nothing you type is sent anywhere.

How to use the JSON formatter

  1. Paste your JSON into the box.
  2. Press Format to indent it neatly with 2 spaces, Minify to remove all extra whitespace, or Validate to check that it is well-formed JSON.
  3. If the JSON is invalid, read the error message. It shows the line and column where the problem was found.
  4. Use Copy to copy the result, or Clear to start again.

Everything runs in your browser; nothing you paste is uploaded. It is still a good habit to remove passwords and API keys before pasting data into any web page.

The JSON rules that trip people up

JSON is defined in RFC 8259. It looks like a JavaScript object, but it is much stricter. A JSON value can only be an object, an array, a string, a number, true, false or null.

MistakeInvalidValid
Single quotes{'city': 'Pune'}{"city": "Pune"}
Unquoted key{city: "Pune"}{"city": "Pune"}
Trailing comma["HTML", "CSS",]["HTML", "CSS"]
Comments// noteNot allowed at all
Capital literalsTrue, NULLtrue, null
Leading zero0077 or "007"
JavaScript-only valuesundefined, NaNnull

Here is a small invalid example with three of those mistakes, followed by the fixed version:

{
  'name': 'Priya',
  city: "Chennai",
  "skills": ["HTML", "CSS",]
}
{
  "name": "Priya",
  "city": "Chennai",
  "skills": ["HTML", "CSS"],
  "available": true,
  "manager": null
}

Reading the error message

The line and column show where the parser gave up, which is not always where the mistake is. A missing comma at the end of one line is often reported at the start of the next line, because that is where the parser met something it did not expect. Look at the reported spot and just before it. The exact wording of the message comes from your browser, so it can differ between Chrome, Firefox and Safari.

Format or minify?

JSON allows any amount of whitespace between its parts, so formatting and minifying change only the layout, never the data. The JSON formatter’s Format button is for people: formatted JSON is easier for people to read and compare. Minified JSON is smaller, which suits data sent over a network or stored in a file. Here is the valid example above, minified:

{"name":"Priya","city":"Chennai","skills":["HTML","CSS"],"available":true,"manager":null}

Doing the same in JavaScript

Browsers have JSON support built in. JSON.parse() turns JSON text into a value and throws an error if the text is invalid. JSON.stringify() does the opposite; its third argument sets the indent.

const text = '{"city":"Madurai","pin":"625001"}';
const data = JSON.parse(text);

console.log(data.city);                   // Madurai
console.log(JSON.stringify(data));        // minified
console.log(JSON.stringify(data, null, 2)); // 2-space indent

Tip: Keep values such as PIN codes and phone numbers as strings when leading zeros or exact digits matter. Numbers in JSON cannot start with a zero.

Learn more

Frequently asked questions

Is JSON the same as a JavaScript object?

No. JSON is a text format. It borrows JavaScript’s object and array syntax but is stricter: double-quoted keys and strings only, no trailing commas, no comments, and no undefined or functions.

Can I add comments to JSON?

Not in standard JSON. Some tools accept variants such as JSONC or JSON5 for configuration files, but a standard JSON parser such as JSON.parse() will reject comments.

What happens with duplicate keys?

RFC 8259 says names within an object SHOULD be unique, and different software handles duplicates differently. In JavaScript, JSON.parse() keeps the last value. Avoid duplicates so the data means the same thing everywhere.

Does Validate check that my data has the right fields?

Validate checks the syntax: whether the text is well-formed JSON. Checking that particular fields exist or have the right type needs a separate schema check in your own code.

More free tools

All tools

Image Compressor

Shrink JPG, PNG and WebP images in your browser. Up to 20 at a time, nothing uploaded.

Image Resizer

Resize a JPG, PNG or WebP image by pixels or percentage, with an aspect-ratio lock. Runs in your browser.

PDF Compressor

Make scanned and image-heavy PDFs smaller, right in your browser. Three levels, nothing uploaded.