Free developer tool

JSON Formatter and Validator

Paste your JSON and the tool checks that it is valid, then formats it with indentation or compresses it into one line. Errors are explained in plain words.

Report a problem or suggest a fix for this tool

What is json formatter and validator?

JSON is the standard format for data in APIs, config files and web apps. A single missing comma or quote breaks it, and reading minified JSON by eye is hard.

This tool validates the syntax with the same parser that browsers use, then pretty prints it so you can read the structure, or minifies it to save bytes.

How to use the json formatter and validator

  1. Paste your JSON into the box.
  2. Choose indentation or tick minify.
  3. Press Calculate and copy the output.

How the json formatter and validator works

The text is parsed with JSON.parse. If it fails, the parser message is shown. If it succeeds, the object is written back with JSON.stringify using your chosen indentation.

Worked example

The compact text {"a":1,"b":[2,3]} becomes a multi line version with each key on its own line.

Common uses of the json formatter and validator

  • Reading an API response that arrives as one long line.
  • Finding the missing comma or quote that breaks a config file.
  • Minifying JSON before sending it over the network.
  • Preparing sample data for documentation.
  • Checking a webhook payload during debugging.

Tips and common mistakes

Common errors are trailing commas, single quotes around strings and unquoted keys. JSON allows none of these.

Do not paste secrets or private tokens into online tools unless you trust them. This one works locally in your browser.

Background: what to know before you rely on it

JSON, short for JavaScript Object Notation, was popularized by Douglas Crockford in the early 2000s as a lighter alternative to XML. It is now the default format for web APIs and many config files. It supports objects, arrays, strings, numbers, booleans and null, and nothing else. There are no comments, no trailing commas, no single quotes and no undefined values, which is why hand edited files often fail. Formatting a file does not change its meaning, only its whitespace. Minifying removes whitespace to save bytes, which matters for large payloads but makes reading harder, so keep a formatted copy for people.

Private, free and fast

This tool runs entirely in your browser. What you type or choose is not uploaded to a server and is not saved after you close the page, which keeps it fast and private. It is free to use as often as you like. See more in all developer tools, or browse the full list of tools.

Field by field guide

  • JSON: Type or paste your text here. Use a new line for each entry where the label says so.
  • Indentation: Choose one of: 2 spaces; 4 spaces; Tab.
  • Minify instead: Tick to turn this option on.

Change one field at a time to see how the result responds, and use the worked example above to check that you get the same answer.

Valid JSON in practice

JSON is strict. Keys must use double quotes, strings use double quotes, and trailing commas are not allowed. The validator tells you the position of the first error.

Expert tips

  • Common errors are trailing commas, single quotes and unquoted keys.
  • Comments are not part of JSON. Remove them or use a format that allows them.
  • Numbers cannot have leading zeros, and NaN or Infinity are not valid values.
  • Use two spaces for indentation to keep files compact but readable.
  • Validate API responses before parsing them in code to avoid runtime errors.

Formatting helps people, and minifying helps machines. Keep the readable version in source control.

Frequently asked questions

How do I validate JSON?

Paste it here and press Calculate. Errors are shown with a message.

What is the difference between format and minify?

Format adds indentation for reading. Minify removes whitespace to save space.

Does it send my data anywhere?

No.

Are comments allowed in JSON?

No. Standard JSON does not allow comments.

Embed this tool on your website

Copy the code below and paste it into your page or blog post. The tool is free to embed, runs in the visitor's browser and needs no account. Please keep the credit link.

Related tools

Results are for information and education. For legal, financial, medical or security decisions, check with a qualified professional. Do not paste live secrets into any website.