Skip to content
Tresna

JSON Formatter & Validator

Paste JSON to validate it and format it. Syntax errors are reported with the exact line and column.

json

Valid JSON114179 B

Valid JSON. 4 keys, 79 B.

Runs in this browser tab. Nothing is uploaded.

Example

How to use this tool

Paste your JSON into the editor and it is validated as you type. If something is wrong, the error panel points at the exact line and column, and the editor marks the position in place. Formatting is applied when you ask for it, by rewriting the document in place, so what you see, what the line numbers count and what Copy gives you are always the same text. Key order is preserved, so reformatting a file does not produce a pointless diff.

  1. 1Paste JSON into the editor, or load one of the examples.
  2. 2Read the status bar. It reports whether the document is valid and how large it is.
  3. 3Choose an indent style, or switch to Minify. Either one rewrites the document in place.
  4. 4Copy the result, or download it as a file.

What this tool actually checks

Validating JSON means confirming it matches the grammar in RFC 8259. In practice that comes down to a short list of rules, and most broken payloads break one of them.

  • Keys and string values are wrapped in double quotes. Single quotes are not a string delimiter in JSON.
  • Keys are unique. A repeated key makes the document ambiguous, so it is rejected rather than silently resolved.
  • There are no comments. Neither `//` nor `/* */` is part of the format, even though JSON5 and JSONC both allow them.
  • No trailing commas after the last item in an object or array.
  • `NaN` and `Infinity` are not numbers in JSON. Use `null`.
  • Numbers have no leading zeros, no leading `+`, and no trailing decimal point.
  • Exactly one value sits at the top level, with nothing after it but whitespace.

Common JSON syntax errors

These account for most payloads that fail to parse. The cause column is the usual reason, not the only one.

What you seeUsual causeFix
Trailing comma before `}` or `]`A comma after the final item, common when deleting a lineDelete the comma, or delete the closing bracket
Expected `:` after the keyA missing colon between a key and its valueAdd `:` after the key
Expected `,` or `}`A missing comma between two membersAdd `,` after the previous value
Keys must be quoted stringsUnquoted key, or a key copied from JavaScriptWrap the key in double quotes
String never closedAn unescaped double quote inside a string valueEscape it as `\"`
Raw line break inside a stringA literal newline typed into a stringUse `\n`
Unexpected content after the top-level valueTwo JSON documents concatenated, or a stray `}`Keep one document only
Duplicate keyA key pasted twice during a mergeRename or remove one of them

Pretty-printed versus minified

The two forms carry identical data. Pretty-printed JSON adds line breaks and indentation, which makes it readable and makes a diff show the line that actually changed. Minified JSON removes every optional space and newline, which makes it smaller.

{ "id": 84213, "tags": ["admin", "billing"] }

{"id":84213,"tags":["admin","billing"]}
The same object, pretty-printed and minified.

Pretty-print what you read and commit. Minify what you send over a network. Because this tool keeps your key order intact, switching between the two never reshuffles the document.

Why key order is preserved

JavaScript objects reorder integer-like keys on their own, so a formatter built naively on `JSON.parse` will silently move `"10"` ahead of `"2"`. The result is a diff that touches every line and hides the one line you changed. This formatter reads keys into an ordered structure and writes them back in the order they arrived.

Keyboard shortcuts

ShortcutAction
Ctrl or Cmd + EnterFormat the document in place
Ctrl or Cmd + Shift + MMinify the document in place
Ctrl or Cmd + Shift + KClear the editor
TabInsert two spaces

Shortcuts are ignored while a modifier-free keystroke would type a character, so they never get in the way of normal editing. The editor is a plain text field, so browser text editing, undo and screen readers all behave normally.

Ctrl or Cmd + K is deliberately left to the browser and to this site's search box. Overriding it would cost you a shortcut that already works everywhere else, and the Copy button is one click away.

Working with larger documents

For multi-megabyte files, a command-line tool is a better fit than a browser tab. `jq` pretty-prints and validates in one pass and streams instead of loading everything at once:

jq . payload.json            # validate and pretty-print
jq -c . payload.json           # validate and minify
jq empty payload.json          # validate only, no output
Equivalent jq commands.

Frequently asked questions

Is my JSON uploaded anywhere?
No. Validation and formatting run in your browser using JavaScript built into the page. There is no request that carries your data, and nothing is written to a server or a log.
Why does my JSON fail even though it looks fine?
Usually one of four things: a trailing comma, single quotes instead of double quotes, an unquoted key, or a comment. The error panel names the specific problem and gives you the line and column.
Can it format JSON with comments or trailing commas?
No, because that is not valid JSON. Those belong to JSONC, which is what TypeScript uses in tsconfig.json, or to JSON5. This tool validates against the strict RFC 8259 grammar and tells you when it finds JSONC syntax, so you can strip the offending parts deliberately.
Does formatting change my data?
No. Whitespace outside of strings is not significant in JSON, so removing or adding it cannot change meaning. Key order is preserved, and string contents are escaped and unescaped without loss.
How large an input can it handle?
Inputs up to 8 MB parse comfortably. Beyond that the tool refuses the input and tells you, rather than locking up the tab. Very large files are better handled with jq on the command line.
Does it support JSON Lines or NDJSON?
No. A stream of newline-delimited JSON objects is not a single JSON document, so the top-level value check rejects it. Split the records first, or use jq with the `-c` flag to process them one at a time.