On-device AI — professional-grade, fully private.

Documents

How to Validate JSON Online (and What Each Error Message Means)

Validate JSON online and understand the error: trailing commas, single quotes, unquoted keys, comments, a BOM, duplicate keys and long numbers, with fixes.

Updated November 8, 20269 min read

To validate JSON, paste it into the JSON validator or drop the .json file on it and press Validate. Valid JSON gets a green verdict with its root type and structure. Invalid JSON gets a red verdict and a list of every error at once, each with its line, column and a caret under the exact character. The hard part is usually not finding that something is wrong but understanding the message, because every program words it differently. This guide explains what the common messages mean, which "errors" are really a different dialect of JSON, why a perfect file can fail at position 0, and the two problems that pass every parser without a sound.

How to validate JSON online, step by step

1

Paste or add the JSON

Open the JSON validator and paste the text into the editor, or drop a file. It accepts .json, .jsonc, .json5, .ndjson, .jsonl, .geojson, .webmanifest, .har, .map and .txt. Minified and indented JSON both work.

2

Leave Document type on Auto

Auto reads the text as one JSON document. If it looks like one record per line, the tool offers to check it as NDJSON instead of changing it on its own.

3

Press Validate

A pass shows the root type (Object, Array and so on), the number of keys or items, and a structure report: nodes, maximum depth, objects, arrays, keys, lines, size and the encoding it read. A fail lists every error with Ln and column; press Go to to jump the cursor to it.

4

Read the warnings as well

Duplicate keys and numbers that lose precision appear as warnings. They do not change the verdict, because any parser will accept them, but they are where data quietly goes missing.

5

Fix by hand or take the repaired copy

If the only problems are comments, trailing commas, single quotes and the like, a repaired strict-JSON copy is offered. Press Use the repaired JSON to load it into the editor, or Download repaired .json.

What JSON error messages actually mean

Every language and app has its own wording for the same handful of faults, and the position it reports is where the parser gave up, which is often one character after your mistake. This table translates the typical wording you meet elsewhere into the cause and the message the validator shows for it.

Typical message elsewhereWhat it usually meansWhat the validator says
Expected double-quoted property name / Expecting property name enclosed in double quotesA trailing comma before }, a single-quoted key or an unquoted keyA trailing comma before the closing bracket; or the key is not quoted
Unexpected token / Expecting valueSomething that is not a JSON value: a comment, NaN, undefined, True or a stray characterJSON does not allow comments; or the literal is not a JSON value
Expecting ',' delimiterTwo members or items with no comma between themA comma is missing before this value
Unexpected end of JSON inputA bracket or brace never closed, or the text was cut offAn object (or array) is opened and never closed
Unterminated string / Bad control character in string literalA missing closing quote, or a real line break or tab inside a stringThis string is never closed; or a control character has to be escaped
Unexpected non-whitespace character after JSON / Extra dataTwo documents pasted together, or one record per lineThe JSON value ends before this; everything from here on is extra
Unexpected token at position 0 / Unexpected UTF-8 BOMInvisible bytes before the first brace, or the file is not JSON at allThe mark is stripped and the encoding is reported

A "position" in such messages counts characters from zero, so position 0 is the very first character and position 7 is the eighth. Line and column count from one. The validator gives you all of these, plus a byte offset for scripts, and computes them itself, so the location is the same whichever browser you use.

Every error at once with line, column and a caret, plus duplicate keys, precision warnings, JSON Schema and repair. Free: pasted text or one file up to 25 MB, with every check included. Pro: up to 100 files in one pass and machine-readable JSON and CSV reports. It all runs on your device, not our servers.

Validate JSON

Trailing commas, single quotes, unquoted keys, comments: broken or a dialect?

Many files reported as invalid JSON are not damaged at all. They are written in a looser dialect that your editor reads happily and a strict parser refuses. Knowing which one you have tells you whether to fix the file or fix the program reading it.

  • JSONC (JSON with comments) adds // and /* */ comments and trailing commas. tsconfig.json, .eslintrc and most editor settings files are JSONC. They work in the editor and fail in a pipeline that expects plain JSON.
  • JSON5 also allows unquoted keys, single-quoted strings, hexadecimal numbers, a leading plus or decimal point, and NaN and Infinity.
  • A Python dictionary printed from a script looks like JSON but uses True, False and None, and often single quotes.
  • Text from a word processor may contain typographic quotes (“ ”) instead of straight ones. They look right and are not JSON.

When the text is one of these, the validator says so in plain words (for example, that it is JSONC rather than broken JSON) and lists which constructs are responsible. The repair works from what the scanner found, so a // inside a URL or a comma inside a quoted value is never touched. NaN and Infinity have no JSON spelling and become null, and that change is called out. If real syntax errors remain alongside the dialect, no repaired copy is offered. For tidying the result into readable indentation, see how to format JSON online.

Why a perfect file fails at position 0: BOM and UTF-16

If an error points at position 0, line 1, column 1, and the file looks fine, suspect the bytes you cannot see. A UTF-8 byte-order mark (BOM) is three bytes, EF BB BF, written in front of the text by some Windows tools, including PowerShell's Out-File, .NET's StreamWriter and Excel's UTF-8 export. A strict parser sees an unexpected character before the opening brace and rejects a document that is otherwise correct.

UTF-16 is worse: Windows PowerShell writes it when no encoding is given, and read as UTF-8 it looks like a NUL byte after every character. The validator detects both, validates the document as if the mark were not there, and reports the encoding it used in the structure report. To fix the file for other programs, save it again as UTF-8 without a BOM; in PowerShell, pass an explicit encoding to the command that writes it. A file that is not text at all, such as an image renamed to .json, is refused with that reason instead of a confusing syntax error.

Valid but wrong: duplicate keys and long numbers

Two problems produce no error in any parser, which is why they reach production. The first is a duplicate key. JSON allows the same key twice in one object, and the usual behaviour is to keep the last value and drop the first without a word, so {"a": 1, "a": 2} quietly becomes {"a": 2}. The validator reports each repeat inside one object with a JSON Pointer to it, such as /users/3/email. The same key in two different objects is normal and is not reported.

The second is a number too long to store exactly. Most parsers read JSON numbers as 64-bit floating point, which holds whole numbers exactly only up to 9,007,199,254,740,991. 12345678901234567890 comes back as 12345678901234567000, with no error. Database IDs, order numbers and long decimals are where this bites. The validator shows the exact literal next to the value a parser will produce; 1e400, which overflows to Infinity, is flagged too. The fix is on the sending side: send such values as strings. Both checks are on by default under Extra checks and can be switched off.

Checking the shape with a JSON Schema

Valid syntax only means the text parses. Whether it has the fields a program expects is a separate question, and a JSON Schema answers it. Paste a schema into the JSON Schema box in the settings and the document is checked against it after the syntax check. Draft 2020-12 and draft-07 are supported; the draft is read from $schema, or assumed and stated when the schema does not declare one. Each failure comes with a JSON Pointer and the line it is on, with messages such as "The required property id is missing" or "Expected string, found number".

Two details catch people out. A $ref that points to another server is reported and not fetched, so your schema stays on your device; include the definitions in the schema itself. And "format": "email" is a note, not a rule, as both drafts define it, so a bad address passes unless you tick Treat format as a rule, not a note. The document has to parse first; a schema is not checked against JSON with syntax errors.

Log files and one record per line

Logs, data exports and bulk API bodies are often NDJSON or JSON Lines: one JSON value per line. Read as one document, such a file fails with a single unhelpful error about extra content at the start of line 2. Switch Document type to NDJSON (or accept the prompt) and every line is checked as its own record, with each fault given its record number as well as its line and column. The final newline is not counted as a record, Windows line endings are handled, and a blank line in the middle is reported, because the format has no empty records. Schema validation applies to a single document, so it is not available in NDJSON mode.

Free and Pro limits

FreePro
InputPasted text or one file at a timeUp to 100 files in one pass
SizeUp to 25 MBLimited by your device
ChecksEvery error, warnings, JSON Schema, NDJSON, repairThe same
ReportText report to copy or downloadAlso JSON and CSV reports, and one ZIP for a batch

Everything that decides whether a document is valid is free. If a file is over the cap and you only need part of it, the JSON viewer lets you browse the structure. If your data started as YAML or CSV, convert it first with YAML to JSON or CSV to JSON. If every quote has a backslash in front of it, the JSON has been stored inside a string; unescape it and then validate.

Frequently asked questions

How do I check if a JSON file is valid?

Paste the text or drop the file into the JSON validator and press Validate. A green Valid JSON verdict means it follows the JSON standard (RFC 8259); a red Invalid JSON verdict lists every error with its line and column.

Why does my JSON say unexpected token at position 0?

Usually the file starts with a UTF-8 byte-order mark or is saved as UTF-16, so the parser meets an invisible character before the first brace. Save it as UTF-8 without a BOM. Less often the file is not JSON at all, such as an HTML error page saved as .json.

Are trailing commas allowed in JSON?

No. Standard JSON does not allow a comma before } or ]. JSONC and JSON5 do, which is why the same file works in an editor and fails elsewhere. Remove the comma, or take the repaired copy the validator offers.

Can JSON have comments?

Not in standard JSON. Files with // or /* */ comments are JSONC. The validator names the dialect and can give you a strict copy with the comments removed; it leaves a // inside a string, such as a URL, alone.

Why is my JSON valid but data is missing?

Check the warnings. A key that appears twice in one object keeps only its last value, and a number above 9,007,199,254,740,991 is rounded when parsed. Neither causes an error, and the validator reports both.

Is it safe to validate private JSON online here?

Yes. The check runs on your device, not our servers, so API responses, tokens and config files are not uploaded. Once the page has loaded it keeps working with the network disconnected.

Keep reading

More in Documents →