Skip to content
StringToJSON

Validate

Find the exact character that breaks your JSON.

No vague error messages. Get the line, the column, and a button that puts your cursor on the offending token.

JSON

0 B

Normalized JSON

0 B

Output appears here.

Ready. Paste something above.

Everything runs locally in your browser — your data never leaves this page. Press⌘/Ctrl +Enter to run.

What the validator checks

It parses your input with the browser's own JSON.parse — the same implementation that will run in your application. If it passes here, it will parse there. The result panel shows the normalized document plus a quick structural summary: the top-level type, total key count, and maximum nesting depth.

Reading the error

A failure reports a message, a line and a column. The column points at where the parser gave up, which is usually one character past the real mistake — a missing comma is discovered when the next key arrives, not where the comma should have been. Look at the end of the previous line first.

The errors you will actually hit

  • Trailing comma[1, 2, 3,]. Valid JavaScript, invalid JSON. This is the single most common failure.
  • Single quotes{'id': 1}. JSON strings are double-quoted, always.
  • Unquoted keys{id: 1} is an object literal from JavaScript source, not JSON.
  • Unescaped control characters — a raw newline or tab inside a string must be written as \n or \t. See the escape tool.
  • Non-finite numbersNaN, Infinity andundefined are not part of the grammar. Serialize them as null or a string.
  • A byte-order mark — an invisible U+FEFF at the start of a file trips many parsers. If the error points at column 1 of line 1 and the line looks fine, this is usually why.
  • Truncated output — a payload cut off by a log limit ends mid-token. The error lands on the last line of the document.

Valid JSON in one paragraph

A JSON document is a single value: an object, an array, a string, a number,true, false, or null. Objects hold comma-separated"key": value pairs with double-quoted keys. Arrays hold comma-separated values. Numbers use decimal notation with an optional exponent and no leading +, no leading zeros, and no hex. Strings are double-quoted, with backslash escapes for ",\, /, b, f, n, r,t, and uXXXX. There are no comments and no trailing commas.

Validating in code

# shell
jq empty data.json && echo valid

# Python
try:
    json.loads(text)
except json.JSONDecodeError as e:
    print(e.msg, e.lineno, e.colno)

// JavaScript
try { JSON.parse(text) } catch (e) { console.error(e.message) }

-- SQL Server / MySQL
SELECT ISJSON(payload);      SELECT JSON_VALID(payload);

Each of these gives a yes-or-no answer plus, in most cases, a position. Python'sJSONDecodeError is the most informative of the group, carrying msg,pos, lineno and colno as separate attributes — log those rather than the payload itself when the input might contain anything sensitive.

After it validates

A document that parses is not necessarily the document you wanted. Once the syntax is clean,format it to read the structure, sort the keys if you are about to diff two responses, or convert it to CSV if it is an array of records headed for a spreadsheet. If it fails here because the payload is escaped rather than malformed, the string to JSON converter will unwrap it first.

Frequently asked questions

Which specification is used?
The browser's native JSON.parse, which implements RFC 8259 / ECMA-404 — the same parser your application will use at runtime.
Why does the reported column differ slightly between browsers?
Engines report parse failures at slightly different offsets: some point at the first unexpected character, some at the end of the last valid token. The line is reliable in every engine; treat the column as the neighbourhood, not the exact culprit.
Can it validate against a JSON Schema?
Not yet — this checks syntax, not shape. For schema validation you want a library such as Ajv, or a dedicated JSON Schema playground.
Is a bare number or string valid JSON?
Yes. Since RFC 7159 any JSON value is a valid document, so 42, "hello", true and null all pass. The older RFC 4627 required an object or array at the top level, which is why some legacy parsers reject them.