# JSON validation: what counts as valid and how to read the error

> What the validator checks (RFC 8259 syntax only), what it deliberately accepts, how line and column are reported, and a table of common mistakes with the messages Chrome-class engines give.

- Tool: [JSON Validator](https://toolsg.com/en/json-validator)
- Language: en (available: en, zh, ms, ta)
- Last verified against official sources: 2026-10-19
- Source site: ToolSG — a planning guide, not official or financial advice. Cite the agencies listed under Sources.

## Key figures at a glance

| Fact | Value | Source |
| --- | --- | --- |
| What is checked | Syntax only, using the browser's JSON.parse — No schema, no types, no required fields. | [IETF — RFC 8259](https://www.rfc-editor.org/rfc/rfc8259.html) |
| Top-level value | Any JSON value is valid — 5, "text", null, [] and {} all pass; RFC 8259 defines a JSON text as a serialized value. |  |
| Duplicate keys | Accepted — The grammar allows them; RFC 8259 only says names SHOULD be unique and behaviour is otherwise unpredictable. |  |
| Error position | Reported when the browser's message includes one — Some messages (for example an unexpected token after a comma) carry no position, so no line and column can be shown. |  |

## What "valid" means here

The validator runs `JSON.parse` on what you paste and shows a green "Valid JSON." banner or a red message. It updates as you type. Empty or whitespace-only input shows nothing. Everything is local to the page.

Valid therefore means "the text matches the JSON grammar", nothing more. It does not tell you whether the data has the fields an API expects (that needs a schema validator), whether a number fits in a 64-bit integer, or whether keys are unique. Examples that pass:

- `5`, `"hello"`, `null`, `true`: RFC 8259 allows any value at the top level.
- `{"a":1,"a":2}`: a repeated key is grammatical.
- `{"a":"\ud800"}`: a lone surrogate escape is accepted by the browser.
- `1e999`: syntactically a number, although a JavaScript double cannot hold it.
- Leading and trailing whitespace or blank lines.

## Reading the message

The page prints `Invalid JSON: <browser message>`. If that message contains `position N` but no line number, the tool appends "(line L, column C)" calculated from the text. Current Chrome-family engines already include "(line 1 column 8)" in the message, so nothing is added; some engines print only a character offset, and the page converts it. Messages with neither (for example `Unexpected token ']', "[1,]" is not valid JSON`) show the problem token and a snippet only. The wording is the browser's own and is not translated.

| Input | Typical message (Chrome-class engine) |
| --- | --- |
| `{"a":1,}` | Expected double-quoted property name in JSON at position 7 (line 1 column 8) |
| `{'a':1}` | Expected property name or '}' in JSON at position 1 |
| `{a:1}` | Expected property name or '}' in JSON at position 1 |
| `[1 2]` | Expected ',' or ']' after array element at position 3 |
| `{"a" 1}` | Expected ':' after property name at position 5 |
| `{"a":1}}` | Unexpected non-whitespace character after JSON at position 7 |
| `{"a":"x⏎y"}` (raw line break) | Bad control character in string literal at position 7 |
| `{"a":"\x41"}` | Bad escaped character |
| `{"a":5.}` | Unterminated fractional number |
| `{"a":-}` | No number after minus sign |
| `[1,]` | Unexpected token ']' (no position) |
| `{"a":.5}`, `{"a":+1}` | Unexpected token (no position): leading `.` and `+` are not allowed |
| `[1]` with a leading BOM | Unexpected token at the invisible character |

## Fixing errors efficiently

1. Go to the reported line and column; the real mistake is usually at or just before it.
2. Look for the usual suspects: trailing comma, single quotes, unquoted key, comment, missing comma between items, raw line break inside a string.
3. If the position points at the very end, a bracket or quote was never closed earlier.
4. If the first character is the problem but looks fine, you may have a byte-order mark or a non-breaking space (U+00A0), neither of which counts as JSON whitespace. JSON whitespace is only space, tab, line feed and carriage return.
5. Fix one thing and read the new message; the banner updates immediately.

> **Tip:** A document that passes here can still break another consumer. Parsers in other languages may reject lone surrogates, reject numbers outside their integer range, or fail on duplicate keys. When it matters, test with the parser you will actually use.

## Common mistakes

- Pasting a JavaScript object (unquoted keys, single quotes, comments) or Python `True`/`None` and expecting JSON.
- Treating "valid" as "correct data": the validator does not check meaning.
- Validating a JSON Lines file (one object per line) as one document; it fails after the first object. Validate each line separately.
- Pasting HTML or a login page returned instead of JSON; the message mentions `<` as an unexpected token.

## Related tools

Pretty-print with the [JSON formatter](https://toolsg.com/en/json-formatter), shrink with the [JSON minifier](https://toolsg.com/en/json-minify), explore valid data in the [JSON viewer](https://toolsg.com/en/json-viewer), or inspect a token with the [JWT expiration checker](https://toolsg.com/en/jwt-expiration-checker).

## Frequently asked questions

**How do I find the error in my JSON?**

The result under the box says Valid JSON, or gives the line and column of the first problem, such as a trailing comma or single quotes.

**Is my JSON sent to a server?**

No. Everything happens in your browser. Nothing you paste is uploaded, logged or stored, which matters when the document contains keys, tokens or personal data.

**Why is my JSON reported as invalid?**

The most common causes are trailing commas, single quotes instead of double quotes around keys and strings, and unescaped line breaks inside a string. The error message gives the line and column of the first problem.

**Does it change my data?**

No. The document is parsed and re-serialised, so only whitespace changes. Key order is preserved and values are untouched.

**Can it handle large documents?**

Yes, within your browser's memory. Documents of a few megabytes are fine; extremely large files may make the page pause briefly while it parses.


## Sources

- [IETF — RFC 8259, The JSON Data Interchange Format](https://www.rfc-editor.org/rfc/rfc8259.html) — Grammar, top-level values, duplicate names.
- [ECMA-404 — The JSON data interchange syntax](https://ecma-international.org/publications-and-standards/standards/ecma-404/)
- [MDN — JSON.parse()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse)
