TessaCodeTools

Free Online JSON Formatter & Validator

Pretty-print, minify, and validate JSON as you type. When something is wrong you get the exact line, column, and a plain-language explanation, not a cryptic token error. Nothing is uploaded.

json in1 lines · 166 B
try:
formatted
248 B
{
  "user": {
    "id": "9f2b",
    "name": "Nick Osborne",
    "roles": [
      "owner",
      "admin"
    ],
    "active": true,
    "lastSeen": "2026-09-11T13:22:04Z"
  },
  "plan": {
    "tier": "pro",
    "seats": 3,
    "renewsAt": null
  }
}

valid JSON · 10 keys · 3 objects · 1 arrays · depth 4

parsed locally

Why JSON breaks, and how to read the error

Almost every invalid JSON document fails for one of four reasons, and all four are things that would be perfectly legal in a JavaScript file. That is the trap: JSON looks like a JavaScript object literal but is a much stricter subset.

The most common is a trailing comma before a closing brace or bracket. Next is single quotes, which JSON does not accept anywhere: strings and keys both require double quotes. Third is unquoted keys, so{ name: 1 }has to become{ "name": 1 }. Fourth is comments: JSON has no comment syntax at all, which surprises people pasting from a tsconfig or a Kubernetes manifest.

The validator above names whichever of these it finds and points a marker at the exact character. That is deliberate. Browsers throw wildly different messages for the same broken document, and none of them tell you the line number reliably.

Format, minify, or sort

Formatting is for reading: indentation and line breaks expose the shape of a deeply nested API response at a glance. Minifying is for shipping: stripping optional whitespace typically cuts 15-30% off a pretty-printed payload, and over a busy API that adds up. The parsed data is byte-identical either way, so it is purely a question of who is reading it next, a human or a socket.

Sorting keys is the underrated option. JSON objects have no defined key order, so two responses carrying the same data can serialize their fields differently. Alphabetize both and adiffsuddenly shows only the values that actually changed, which makes this the fastest way to compare two API payloads or spot config drift between environments.

Doing it in code

The third argument toJSON.stringifyis the one most people forget:

const pretty = JSON.stringify(data, null, 2);   // indent
const tight  = JSON.stringify(data);            // minify

// Sort keys deeply, for stable diffs
const sorted = JSON.stringify(data, Object.keys(data).sort(), 2);

On the command line,jq . file.jsonpretty-prints,jq -c .minifies, andjq -S .sorts keys. Python ships the same thing:python -m json.tool. Use those for large files; use this page when you have a payload on your clipboard and want an answer in one paste.

Three gotchas that survive validation

Large integers lose precision. JSON numbers are IEEE-754 doubles, so anything past 2^53 silently rounds. A Twitter-style 64-bit ID like9007199254740993comes back one digit different, and the document was perfectly valid the whole time. This is why mature APIs send big IDs as strings.

Duplicate keys are legal. The spec does not forbid{ "a": 1, "a": 2 }, and every mainstream parser quietly keeps the last one. If two systems disagree about which wins, you get a bug that no validator will ever flag.

There is no date type, and no NaN. Dates are just strings by convention, so use ISO 8601 and be consistent.NaNandInfinityare not valid JSON at all:JSON.stringifyturns them intonullwithout warning you, which is a fun one to debug at 2am.

Frequently asked questions

Is my JSON uploaded anywhere?+

No. The parser runs in your browser, so the document never leaves the tab. That makes it safe to paste API responses or config files containing keys and customer data.

Why does my JSON fail to parse when it looks fine?+

The four usual culprits are a trailing comma before a closing brace, single quotes instead of double quotes, unquoted object keys, and // comments. All four are legal JavaScript but invalid JSON, and the error panel names whichever one it finds along with the exact line and column.

What is the difference between formatting and minifying?+

Formatting adds indentation and line breaks so a human can read the structure. Minifying strips every optional byte of whitespace to shrink the payload for transport. The data is identical either way.

Does sorting keys change my data?+

No. Object keys have no defined order in JSON, so alphabetizing them produces an equivalent document. Array order is preserved untouched, because in an array the order is the data.

How large a file can it handle?+

Files up to about 5 MB parse comfortably in well under a second. Past that the browser is doing real work and you are better off with jq on the command line.