ToolBit

JSON Formatter and Validator

Format and validate JSON in your browser.

Output
Press Format or Minify

Runs in your browser. Nothing is uploaded.

Paste JSON into the input and press Format, or Ctrl+Enter (Cmd+Enter on a Mac). Minify removes all whitespace between tokens instead. Formatting runs only when you ask, not while you type. Changing Indent (2 spaces, 4 spaces or Tab) or Sort keys repeats your last action on the current input.

The tool changes nothing except whitespace between tokens. Numbers and strings are kept exactly as written, so 12345678901234567890, 1.0, 1e5, -0 and "\u00e9" come out unchanged, and emoji are preserved. Under the output you see its size in bytes, the top-level type with its key or item count, and the nesting depth. If the input is invalid, the message appears under it with a line and column, the cursor jumps there and the offending character is selected. The previous output stays, dimmed and marked as from the previous input.

Example

Input:

{"name":"Ada","tags":["a","b"],"empty":{},"n":12345678901234567890}

Output with 2 spaces:

{
  "name": "Ada",
  "tags": [
    "a",
    "b"
  ],
  "empty": {},
  "n": 12345678901234567890
}

The status line reads 97 bytes · object, 4 keys · depth 2. Empty {} and [] stay on one line. A mistake such as {"a":1,} gives “Trailing comma before ‘}’ at line 1, column 7”.

Limitations

  • Input is limited to 1,000,000 bytes of UTF-8 (1 MB), as in the Base64 tool. Larger input gets a message and is not formatted. Output is capped at 10,000,000 characters, which only extreme nesting reaches. Nesting depth itself has no limit.
  • Only strict JSON (RFC 8259) is accepted: no comments, trailing commas, single quotes, unquoted keys, NaN, Infinity or undefined. Leading zeros, +1, .5, 1. and hex numbers are rejected. Raw tabs and newlines inside strings must be escaped. Whitespace means space, tab, LF or CR only, so a non-breaking space is an error.
  • A leading byte order mark is ignored. A top-level scalar such as 42, "text", true or null is valid.
  • Duplicate keys are kept in the output, and the first one is reported with its line. Keys are compared after escapes are decoded, so "a" and "\u0061" are duplicates.
  • Sort keys works at every level and compares UTF-16 code units, as RFC 8785 does, not locale rules. "B" sorts before "a". Duplicate keys keep their original order.
  • Output always uses LF line endings.
  • There is no schema validation, tree view, syntax highlighting or file upload.

FAQ

Why does JSON not allow trailing commas?

The grammar in RFC 8259 puts a comma only between members. [1, 2,] and {"a": 1,} are errors in JSON.parse too. Remove the last comma.

Can JSON use single quotes?

No. Strings and keys need double quotes. The tool reports “Strings must use double quotes” and selects the quote.

Can JSON have comments?

No. The standard has no comment syntax, so // and /* */ are rejected. JSONC and JSON5 allow them but are different formats. Strip the comments first.

What is the difference between JSON and a JavaScript object?

JSON is text. Keys must be double-quoted strings, and values are limited to objects, arrays, strings, numbers, true, false and null. A JavaScript object literal also allows unquoted keys, single quotes, trailing commas, functions and undefined.

Why do large numbers change in other tools but not here?

JSON.parse reads every number as a 64-bit float, so 12345678901234567890 becomes 12345678901234567000. Anything that parses and re-serializes this way loses digits beyond about 15 to 17. This tool never converts numbers, so the digits you paste are the digits you get.