JSON Formatter & Validator

Paste JSON to beautify it with clean indentation, compress it into a single line, or check that it is valid. If something is wrong, you get a clear error with the line and column number.

  • 100% free
  • No sign-up
  • Runs in your browser
  • Updated

How to use the JSON Formatter & Validator

  1. 1Paste your JSON into the input box.
  2. 2Click Format and choose 2 spaces, 4 spaces or tab indentation to make it readable.
  3. 3Click Minify to remove all unnecessary whitespace, or Validate to check the syntax.
  4. 4If there is an error, use the line and column shown to find and fix it.
  5. 5Click Copy to copy the result, or Clear to start again.

What is JSON?

JSON (JavaScript Object Notation) is a lightweight text format for storing and exchanging data. It is the most common format for web APIs, configuration files and data exports. A JSON document is built from objects (key and value pairs inside curly braces), arrays (ordered lists inside square brackets), strings, numbers, true, false and null. JSON Web Tokens also carry their data as JSON, which you can inspect with the JWT decoder.

JSON received from an API is often minified to save bandwidth, which makes it hard to read. Formatting adds line breaks and indentation so you can see the structure at a glance. Minifying does the reverse, which is useful before embedding JSON in code or sending it over a network. Binary data such as images cannot be placed in JSON directly and is usually stored as text with the Base64 encoder.

Common JSON errors and how to fix them

Trailing commas are the most frequent problem. A comma after the last item in an object or array, such as [1, 2, 3,], is allowed in JavaScript but not in JSON. Remove the final comma. Strings and keys must use double quotes; single quotes are not valid, so 'name' must become "name". Object keys must always be quoted, so {name: 1} is invalid while {"name": 1} is valid.

JSON does not support comments of any kind, so lines starting with // or blocks wrapped in /* */ must be removed. Other common mistakes include missing commas between items, unclosed brackets or braces, unescaped double quotes or line breaks inside strings, and values like undefined, NaN or Infinity, which are not part of the JSON standard.

Reading the error message

When validation fails, the tool reports the line and column where the parser stopped. The real mistake is often just before that point: a missing comma, for example, is usually reported at the start of the next item. Jump to the position shown, then look at the previous line or character if nothing seems wrong there.

Private by design

JSON often contains API keys, tokens or personal data. This formatter parses and formats everything locally in your browser using the built-in JSON parser. Nothing you paste is uploaded, logged or stored.

Frequently asked questions

Should I use 2 spaces, 4 spaces or tabs?

All three produce equally valid JSON, so the choice is about readability and your project’s conventions. Two spaces is common in JavaScript projects and keeps deeply nested data compact, while four spaces or tabs can be easier to scan. Formatting two documents with the same setting before comparing them in the text compare tool keeps the differences easy to spot.

Does formatting or minifying change my data?

No. Both only change whitespace between tokens. Keys, values and the order of items stay the same, and whitespace inside strings is preserved.

Why is my JSON invalid when it works in JavaScript?

JavaScript object syntax is more relaxed than JSON. It allows single quotes, unquoted keys, trailing commas and comments, none of which are permitted in JSON. Convert these to strict JSON syntax and it should validate.

Can JSON have comments?

No. The JSON standard does not allow comments. Some tools accept extended formats such as JSONC or JSON5 that do, but standard JSON parsers, including this one, will report them as errors.

Is it safe to paste sensitive JSON here?

Yes. All processing happens in your browser and no data is sent to a server or saved. More utilities for working with data are in the developer tools section.

Related tools