Skip to content
codinganthem
All tools/Formatters/JSON Formatter

JSON Formatter

Format, validate, and minify JSON online for free. Instantly catch syntax errors, apply clean indentation, and minify with one click — no sign-up needed.

Valid JSON
105 chars
More
Buy me a coffee

How to format and validate JSON

Paste JSON into the input. The formatter parses it and prints it back with consistent indentation, and the badge shows Valid or Invalid as you type. If the JSON doesn't parse, the error says what went wrong and where, so you can fix it without hunting through a long line.

Use Minify to strip all whitespace before you send a payload or store it. Whitespace between tokens has no meaning in JSON, so formatting and minifying never change the data itself.

Common JSON errors and how to fix them

  • Trailing comma: [1, 2, 3,] or {"a": 1,}. JSON allows no comma after the last item. Delete it.
  • Single quotes: {'name': 'Ada'}. Strings and keys must use double quotes.
  • Unquoted keys: {name: "Ada"} is valid JavaScript but not JSON. Quote every key.
  • Comments: // note or /* note */ aren't allowed in standard JSON. Files like tsconfig.json accept them because their tools use a looser format (JSONC); a strict parser rejects them.
  • JavaScript-only values: undefined, NaN, Infinity and functions have no JSON form. Use null or a string instead.
  • Missing comma between items, often after copying from a log: {"a": 1 "b": 2}.

Example

This input has three errors: single quotes, an unquoted key and a trailing comma.

{'name': 'Ada', tags: ['math',],}

// Fixed:
{
  "name": "Ada",
  "tags": ["math"]
}

Large numbers and precision

The formatter reads numbers the way JavaScript does, as 64-bit floating point. Integers above 9,007,199,254,740,991 can't be stored exactly and come back slightly changed. If an API sends large IDs, it should send them as strings; most large public APIs do this for exactly this reason.

When to use related tools

To see what changed between two JSON documents regardless of key order, use JSON Compare. To get a spreadsheet, use JSON to CSV. To generate types for your code, use JSON to TypeScript.

Frequently asked questions

Why does my JSON say unexpected token?+

The parser hit a character it didn't expect at that position. The usual causes are a trailing comma, single quotes, an unquoted key, a comment, or a missing comma between items. The error message shows the position so you can find it.

Does formatting change my JSON data?+

No. Formatting and minifying only add or remove whitespace between tokens, which JSON ignores. Keys, values and order stay the same.

Can JSON have comments?+

Standard JSON can't. Some tools accept a variant called JSONC (used by VS Code settings and tsconfig.json) that allows comments, but a strict JSON parser like this one rejects them.

Why did a long number change after formatting?+

JavaScript stores numbers as 64-bit floats, so integers larger than 9,007,199,254,740,991 lose precision when parsed. Keep such values as strings in your JSON.