Skip to content
HexSlate

JSON Formatter & Validator

JSON input0 B / 5 MB

Nothing to format yet

Paste JSON into the box. It is parsed as you type.

parsed in 0.1 mslines 0 → 00 B out

What formatting changes

The output is a re-serialisation, not a reprint. Anything JSON.parse does not keep is gone.

  • Numbers are normalised.1.0, 1e0 and 1 all come back as 1, and -0 comes back as 0.
  • Duplicate names collapse. RFC 8259 §4 says names SHOULD be unique and leaves the rest undefined; JavaScript resolves it by last-one-wins, so "a": 1, "a": 2 formats to a single "a": 2.
  • Integers above 253−1 lose precision.JSON.parse produces IEEE-754 doubles, so 9007199254740993 comes back as 9007199254740992. For 64-bit identifiers (snowflakes, Postgres bigint keys) treat this tool as a viewer, not a round trip.
  • Whitespace and original key order are not preserved. Sorting orders keys by UTF-16 code unit, so Z comes before a. Arrays are never reordered, because array order is data.

Where the error line and column come from

They are worked out from the input, not copied from the browser's error message, because the engines disagree. V8 (Chrome, Edge, Node) says at position 24 and drops the position entirely for short inputs. SpiderMonkey (Firefox) says at line 2 column 9 of the JSON data. JavaScriptCore (Safari) gives no position at all. Where an engine does report one, it is recomputed to a line and column that read the same everywhere. Where none does, the pointer falls back to the first recognisable clue in the input, so it can land somewhere else than another browser puts it.

Common problems

  • Trailing comma: {"a": 1,}. Legal in JavaScript, illegal in JSON. Use the strip button, or delete the comma.
  • Comments: tsconfig.json, devcontainer.json and VS Code settings are JSONC, not JSON. Stripping is string-aware, so a // inside "https://example.com" survives.
  • Single quotes or unquoted names: that is a JavaScript object literal or JSON5. Every name and every string in JSON is double-quoted.
  • NaN, Infinity, undefined: JSON has no literal for any of them (RFC 8259 §6). Use null, or a quoted string.
  • A leading byte-order mark: files from PowerShell's Out-File, older Notepad and some Java tooling start with U+FEFF, which JSON.parse rejects at position 0. Stripped here before parsing.

Frequently asked questions

Why did my long number change?

JSON numbers become JavaScript doubles, which hold 53 bits of integer precision, so anything above 9,007,199,254,740,991 is rounded. Every JSON tool built on JavaScript does this. For exact 64-bit integers, transport them as strings.

Can it format JSONC or JSON5?

JSONC yes. JSON5's single quotes, unquoted names and hex numbers are reported rather than rewritten, since rewriting means guessing what you meant.

Does it validate against a JSON Schema?

No. This checks syntax. Schema validation checks whether valid JSON matches a contract of required properties, types and formats.

Is my JSON sent anywhere?

No. Parsing and formatting both happen in this tab, and nothing is written to the address bar either. The JSON people paste into a formatter is very often an API response with a token or personal data in it.