JSON Formatter and Validator

Tidy up messy JSON, or find out exactly which line is breaking it.

Fast, easy and free, your answer appears as you type, and whatever you enter stays on your device.

Paste JSON to format it with 2 spaces, 4 spaces or tabs, minify it to a single line, or optionally sort its keys. If the JSON is invalid you get the exact line and column, the offending snippet, and a plain-words diagnosis of the four classic mistakes, with a one-tap repair. Your JSON stays on your device.

How to use it

  1. Paste your JSONDrop in a response body, a config file or anything else. It is parsed as you type.
  2. Choose the outputPick an indent width, or Minify to strip all whitespace. Tick Sort keys to order object keys alphabetically.
  3. Copy or fixCopy the result. If the input is not valid JSON, read the diagnosis, then press Fix common mistakes to repair the usual culprits.

Formatting and validating in one step

Most of the time you reach for a JSON formatter you are actually asking two questions at once: is this valid, and what shape is it? A response arrives as one unbroken line and you need to see the structure. Or a config file has stopped working and something in it is malformed.

This tool answers both as you type. Valid input is formatted immediately and a line above the result tells you what you have, an object with nine keys, an array of two hundred items, which is often the fact you actually wanted. Invalid input produces an error naming the line and column.

Why the error message is worth having

Browsers do not agree on how to report a JSON error. Chrome and Node now append a line and column; other engines give only a character offset such as "position 428", which is not much help when you are staring at a 400-line file. This tool derives the line and column itself and strips the engine's own suffix, so you get the same clear message wherever you run it.

In practice, most invalid JSON fails for one of four reasons: a trailing comma after the final element, single quotes where the specification demands double, object keys left unquoted, or comments. Each is legal JavaScript, which is exactly why the mistakes are so easy to make.

Minifying and sorting

Minify strips every optional space and newline, which is what you want when embedding JSON in an environment variable, a query string or a single-line log entry. On large documents the saving is substantial.

Sorting keys is most useful when you want to diff two documents that contain the same data in a different order. Sort both and the diff shows only what actually changed. Array order is deliberately left alone, objects are unordered by specification, but arrays are not, and reordering them would alter the meaning.

The precision caveat

One limitation is worth stating plainly, because it can lose data silently. JSON numbers are parsed as JavaScript doubles, so an integer larger than about nine quadrillion, or a decimal with more than roughly seventeen significant digits, may not survive the round trip unchanged. If your document carries large database identifiers or precise monetary values, check them, and note that this is the reason such values are conventionally sent as strings.

Your data stays yours

Whatever you paste stays on your device, never uploaded, never logged, gone when you close the tab. Given how often the JSON in question is a live API response full of real customer data, that is rather the point.

JSON was discovered, not invented

Douglas Crockford insists he did not invent JSON, he discovered it. In April 2001 he and Chip Morningstar needed a way for browsers and servers to exchange data, and realised JavaScript's own object literal syntax was already perfect for the job. Crockford wrote a one-page specification, bought json.org, and refused to formalise it further for years, saying the good thing about JSON is that it is finished. It quietly displaced XML across the web, one curly brace at a time.

Questions people ask

Is my JSON uploaded anywhere?

No. The parsing and formatting run in JavaScript inside your browser tab. Nothing is transmitted, which matters because the JSON people format is so often an API response containing tokens, customer records or internal identifiers.

Why does it say invalid JSON when my file looks fine?

The usual causes are a trailing comma after the last item, single quotes instead of double quotes, unquoted object keys, or a comment. All four are valid JavaScript but none are valid JSON. The error message gives the line and column so you can go straight to it, and when the cause is one of these classics the tool names it in plain words and offers to fix it. Note that a trailing comma is reported at the position of what should have followed it, so the error often points at the closing brace on the next line.

What does Fix common mistakes actually change?

Exactly four things: it removes trailing commas, turns single quotes into double quotes, wraps unquoted keys in quotes, and straightens curly quotes pasted from Word or a chat app. Text inside your string values is never touched, and the button only appears when the repair would genuinely produce valid JSON. Valid input is never altered at all.

Can it handle JSON with comments, or JSON5?

No. This validates strictly against the JSON specification, which allows neither comments nor trailing commas. That is deliberate, a formatter that quietly accepts them would let you ship a file that the receiving system rejects.

Does sorting keys change my data?

It changes the order keys appear in, nothing else. The JSON specification treats objects as unordered, so a sorted document is equivalent to the original for any conforming parser. Array order is never touched, because that would change what the document means.

What is the size limit?

None is imposed. Very large documents (tens of megabytes) may make typing feel sluggish, since the whole input is reparsed on each keystroke. Pasting rather than typing avoids that.

Are very large or very precise numbers preserved exactly?

Not always. JSON numbers are parsed into JavaScript doubles, so integers beyond about 9 quadrillion (2^53) and figures with more than about 17 significant digits can lose precision on the round trip. If you are handling large IDs or financial values, this is a real risk, that is exactly why such values are usually transmitted as strings.

Does it work offline?

Yes. Once the page has loaded, the formatter needs no network connection.