DEVELOPER GUIDE

How to format JSON (and fix common errors)

Make JSON readable, validate its syntax, and understand what a formatter can and cannot fix.

5 min read•DevToolbox editorial

Start with a valid JSON document

JSON represents values using objects, arrays, strings, numbers, booleans, and null. Object keys and string values must use double quotes. Unlike JavaScript, JSON does not accept comments, undefined, or trailing commas.

{"name":"Alex","active":true,"skills":["TypeScript","React"]}

Format for people, minify for transport

Paste the document into the formatter, choose two spaces, four spaces, or tabs, and select Format JSON. Indentation reveals the structure without changing the parsed values. Minify removes optional whitespace; it is useful when you need a compact payload.

{
  "name": "Alex",
  "active": true,
  "skills": ["TypeScript", "React"]
}

Read the first error carefully

A parse failure often points to the character after the actual mistake. Check the preceding comma, quote, and closing bracket. Fix one error and validate again. Browser engines report locations differently, so an exact line and column may not always be available.

Keep precision in mind

JavaScript cannot exactly represent every large integer. If an identifier exceeds 9,007,199,254,740,991, represent it as a quoted string before parsing. Duplicate object keys also collapse to the last value; formatting is not a lossless repair tool for malformed or ambiguous documents.

Put it into practice with a free tool that runs in your browser.
Open JSON Formatter