JSON Formatter & Validator

Paste JSON to format, minify and validate it — with exact line/column error locations, a collapsible tree view, key sorting and one-click copy or download.

Type or paste any JSON (or open a .json file) and the page validates it as you type. When it is valid you can pretty-print it with your choice of indentation, minify it back to a single line, sort object keys, explore it as an interactive collapsible tree, and copy or download the result. When it is invalid you get the exact line and column, a caret pointing at the problem character, and a plain-English explanation for the usual suspects — trailing commas, single quotes, comments, NaN and friends.

🔒 100% private — nothing is uploaded or stored. Your JSON is parsed, formatted and validated entirely in your browser with plain JavaScript. It never touches our servers, is never written to disk, and the page keeps working even if your internet connection drops.

Your JSON

Tip: press Ctrl+Enter (or ⌘+Enter) inside the box to format.

Paste or type JSON above — validation runs as you type.

Why JSON fails validation — the usual suspects

Strict JSON (defined in RFC 8259) is unforgiving. Almost every “my JSON is broken” report is one of these:

MistakeExampleWhy it fails
Trailing comma{"a": 1,}Strict JSON forbids a comma before ] or } (unlike JavaScript object literals).
Single quotes{"a": 'b'}Strings — and keys — must use double quotes.
Comments{"a": 1} // doneJSON has no comment syntax. // and /* */ belong to JSONC / JSON5.
Unquoted keys{a: 1}Every object key must be a double-quoted string.
NaN / Infinity / undefined{"a": NaN}None of these can be represented in JSON — use null (or a number) instead.
Duplicate keys{"a": 1, "a": 2}Technically allowed, but most parsers silently keep the last value — usually a bug. This tool flags it as a warning.
Byte Order Mark{"a": 1}An invisible character some editors write at the start of a file. Save as UTF-8 without BOM.
Multi-line stringsa real newline inside "…"A string cannot contain a raw newline — escape it as \n.

Strict JSON vs JSON5 / JSONC

If your data “almost” parses, it is probably a JSON dialect. JSON5 (standardised in 2023) relaxes the grammar: comments, single quotes, trailing commas, unquoted keys, NaN/Infinity and hex numbers. JSONC is plain JSON plus comments — the format VS Code uses for its settings.json. This tool validates strict JSON only, and the error messages will tell you when a mistake looks like one of those dialects.

How the error location works

Line and column are 1-based, with the column counted from the start of the line (the same convention as most editors). The snippet under the error shows a few lines of context with a ^ caret under the offending character. The parser on this page is written in plain JavaScript — rather than relying on JSON.parse, whose error messages vary by browser and usually only give a character offset — so every error can point at the exact line and column with an actionable message.

Nothing on this page leaves your browser: there is no server round-trip when you paste, format or validate, no analytics on your inputs, and no storage of any kind.


Luke Keam
Thank you for reading. Email me: [email protected]
Luke Keam | techgeek.biz