Skip to content

JSON Formatter and Validator

Format, validate and minify JSON with the exact line and column of every error and duplicate-key warnings. Runs in your browser: nothing is uploaded.

Runs in your browser

Everything happens on your device: nothing you paste or type is sent to our server or stored. A share link holds your settings, and your input only if you choose to include it.

Orders the keys of every object by character code (the order RFC 8785 canonical JSON uses). Arrays keep their order.

Off: strict JSON (RFC 8259), what APIs and JSON.parse accept. On: also reads // and /* */ comments and trailing commas, as in VS Code settings and tsconfig.json. Comments are not kept in the output.

147 characters · 147 bytes (UTF-8) · limit 5 MB

Output: 189 characters.

  • Warning: Kept exactly as typed: $.orderId has more digits than a JavaScript number holds, so JSON.parse (and many APIs) would round it. Send IDs like these as strings.
Valid JSON
Yes
Input size (bytes)
147
Output size (bytes)
189
Nesting depth
2
Object keys
7

Method: JSON, RFC 8259 / ECMA-404 (strict) · FindMySum parser (no library), RFC 8259 (2017)

Off by default. When on, your input is packed into the part of the link after “#”, which browsers never send to any server; anyone you give the link to will see it.

How it works

The tool reads your text with its own parser, written from the JSON grammar in RFC 8259 and ECMA-404 rather than the browser's JSON.parse, so it can keep what JSON.parse throws away: where each value starts, every key in the order you typed it, and every number and string exactly as written. At the first character that breaks the grammar it stops and reports the line, the column and what it expected there instead (a comma, a closing bracket, a key in double quotes).

Formatting changes only the whitespace between values: each nested level is indented by 2 spaces, 4 spaces or a tab, and minifying removes all of it. A number such as 12345678901234567890, which JavaScript would round to 12345678901234567000, is written back digit for digit, and an escape such as \u00e9 stays an escape. Sorting keys orders them by character code, the order the JSON Canonicalization Scheme (RFC 8785) uses.

Strict mode follows RFC 8259 exactly. The JSONC option also accepts // and /* */ comments and trailing commas, as VS Code settings and tsconfig.json files use them; the output is plain JSON without them. Everything runs in your browser and nothing you paste is uploaded.

Standards this tool follows

JSON Formatter and Validator: Find the Error, Then Pretty-Print

By FindMySum · Last reviewed

This JSON formatter checks your JSON against the standard, points to the exact line and column of the first mistake, and then pretty-prints or minifies it. Paste an API response, a configuration file or a log line into the box above; it works in your browser as you type, and nothing you paste leaves your device.

What it checks

JSON has a small grammar and very little tolerance. A document is one value: an object in braces, an array in brackets, a string in double quotes, a number, or one of the words true, false and null. Keys must be strings in double quotes. Numbers can't have leading zeros, a plus sign, or the values NaN and Infinity. Strings can't contain a raw line break or tab. The formatter reports each of these with a plain-language message instead of "unexpected token".

It also flags two things that are valid but risky: duplicate keys, listed with their paths, and numbers too long for JavaScript, such as 19-digit order IDs that most programs would round.

How to use it

  1. Paste or type your JSON. The result updates as you type.
  2. If there is an error, read the message under the output and press "Show it in the input" to jump to the spot.
  3. Choose Format for readable output with 2 spaces, 4 spaces or tabs, or Minify to remove every unneeded space before sending or storing it.
  4. Turn on Sort keys to make two documents easy to compare, or JSONC for files that contain comments.
  5. Copy or download the result.

A worked example

Take {"name":"Ada","langs":["en","fr",],"id":01}. The formatter stops at the comma before ] (line 1, column 33): strict JSON doesn't allow a trailing comma. Remove it and it stops again at 01, because JSON numbers can't start with a zero; an ID like that should be the string "01". With both fixed, formatting gives:

{
  "name": "Ada",
  "langs": [
    "en",
    "fr"
  ],
  "id": "01"
}

Common mistakes

Copying JavaScript instead of JSON. Object literals in code often have unquoted keys, single quotes and trailing commas. They look like JSON but aren't.

Smart quotes and invisible spaces. Text copied from a word processor or a chat app can contain curly quotes or no-break spaces. The error names the character, even when you can't see it.

Concatenated documents. Log files often hold one JSON object per line (JSON Lines). That is many documents, not one, so the formatter stops after the first. Wrap them in an array, or check one line at a time.

When you need the data in another shape, related tools convert between formats, and the Base64 decoder unpacks JSON that arrives Base64-encoded, as in a token or a data URL.

Sources

Frequently Asked Questions

Is my JSON valid if the formatter accepts it?

Yes, in strict mode it is valid JSON under RFC 8259, the standard every JSON parser follows. The checks were tested against the JSONTestSuite collection of valid and invalid documents. Valid JSON can still be wrong for your program: a missing field or a string where a number belongs is a schema question, not a syntax one.

Why does the error point to a line after the real mistake?

The parser reports the first place the text stops making sense, which is sometimes later than the cause. A string that is never closed swallows everything up to the next quote, and a missing comma is only noticed when the next key starts. Look at the reported position and the line before it.

What happens to duplicate keys?

They are kept in the output and reported with their path, such as $.user.id. RFC 8259 only says keys should be unique, so duplicates are valid, but programs disagree on which copy wins: JavaScript keeps the last one, some libraries keep the first and some reject the document. Remove the copy you don't mean.

Why is my large ID number flagged?

JavaScript and many JSON libraries store numbers as 64-bit floating point, which holds integers exactly only up to 9,007,199,254,740,991. Longer IDs are silently rounded when they are parsed. This tool keeps your digits, but the program reading the JSON may not, so send long IDs as strings.

Can I format JSON with comments in it?

Turn on the JSONC option. Comments and trailing commas are then accepted, and the output is standard JSON with them removed, which any parser can read. Strict JSON has no comments at all, so leave the option off when checking data for an API.

Spotted a wrong result or a bug? Report a problem (the link sends the page address only, never what you entered).

May we count your visits with Invoker Analytics? It keeps a random visitor number in your browser. Your calculator inputs are never sent. Privacy policy