JSON Formatter & Validator

Paste JSON to pretty-print, minify, sort keys or browse as a tree. Errors pinpointed by line and column. Free, runs entirely in your browser.

Input
Output

What each button does

Format validates and pretty-prints with your chosen indent — 2 spaces, 4 spaces or tabs. Minify strips all insignificant whitespace for the smallest possible payload (handy for .env values, URL parameters and package.json one-liners). Validate just checks — useful when you only want a verdict. ⌘/Ctrl+Enter inside the input formats too. Sort keys applies recursively to objects at every depth, which is the fastest way to diff two API responses or eyeball a document’s structure. (It can’t reveal duplicate keys — the parser collapses those before sorting; see the FAQ.)

Reading the error report

When JSON fails to parse, the red panel gives you three things: a plain-English message (“trailing comma”, “unterminated string”), the line and column of the first offending character, and a code snippet with a ^ caret under it. Jump to error moves your cursor to that exact offset in the input. Errors are reported one at a time — fix the first, re-check, repeat. For a tour of the usual suspects, see the 12 most common JSON syntax errors.

Strict by design — and why that helps

JSON’s strictness is a feature: six data types, double quotes only, no comments, no trailing commas, one top-level value. That’s why every language can parse it identically — and why tools like JSON.parse, curl, jq and your API client all agree on what’s valid. If your input has comments or single quotes, it may be JSON5 or JSONC rather than JSON; if you need to check structure rather than syntax, that’s JSON Schema territory.

Everything here — sizes included — is measured in UTF-8 bytes and computed on your device. Nothing is uploaded, logged or stored.

Frequently asked questions

Does my JSON get uploaded to a server?

No. This page is a static file; parsing, formatting and the tree view all run in JavaScript inside your browser tab. You can load the page, go offline, and everything still works. The privacy policy covers the small print — there is no account and nothing to leak.

What does the "line N, column M" in an error mean?

It's the exact character where the parser first gave up: line N counting newlines from the top, column M counting characters from the start of that line. The snippet under the message shows the offending line with a ^ caret under the column, and Jump to error places your text cursor on that spot in the input.

Does "Sort keys" reorder my arrays too?

No — only object keys are sorted (A–Z, recursively at every depth). Array order is always preserved because order is meaningful in a JSON array. If you need the sorted output, apply Sort keys before Format or Minify; the toggle re-runs the formatter on already-formatted output.

Why does my JSON fail with "trailing comma" when JavaScript allows it?

JSON is a strict subset of JavaScript's object literal syntax from 1999 — it never adopted trailing commas, comments or single quotes. {"a":1,} is fine in a .js file and invalid in a .json file. The syntax-error guide covers the twelve most common breakages and their fixes.

How big a document can I paste?

Megabytes. Live as-you-type validation pauses above ~1.5 MB so the page stays responsive — press Format or Validate to run it on demand. The tree view expands nodes lazily, 200 children at a time, so even huge API responses stay navigable. The practical limit is your browser's memory, not the tool.

Are duplicate keys an error?

Not a syntax error — the spec (RFC 8259) allows them, and parsers typically keep the last value silently. But {"a":1,"a":2} means different things to different systems, so it's worth hunting them down — with a text scan or a parser that preserves pairs (like Python's object_pairs_hook), not with this tool: JSON.parse has already collapsed duplicates into one key before Sort keys ever runs. Sorting is for readability and diffing, not de-duplication.

Why does the byte size sometimes grow after minifying?

It doesn't — minified output is always ≤ the input unless the input was already minified (then it's identical). What can grow is pretty-printed output: indentation adds two characters of overhead per line on average. All sizes shown are UTF-8 bytes, the same units your HTTP responses are measured in.

Latest articles