JSON Parser

Parse JSON and get clear, actionable syntax error explanations.

Input44 chars
Result
paste JSON and click Parse

Related Tools

Documentation

What is JSON Parser?

JSON Parser validates JSON and, on failure, goes further than a bare syntax error: it inspects the text around the failure point and explains in plain language what likely went wrong — a trailing comma, single quotes, an unquoted key, or a comment. On success it renders the parsed result as a tree, same as JSON Viewer.

How it works

Input is run through the native JSON.parse(). On failure, the tool extracts the character position from JSON.parse's error message, converts it to a line and column, and takes a small snippet of text around that position. A set of regex checks then pattern-matches the snippet: a comma directly before a closing } or ] is flagged as a trailing comma, a quote character (') is flagged as single-quoted strings/keys, a bare identifier followed by a colon is flagged as an unquoted key, and // or /* is flagged as a comment (JSON has none). If none of those patterns match, it falls back to a generic "check the syntax" explanation but still shows the exact line and column.

Features

  • Plain-language explanation of the most common JSON syntax mistakes
  • Line/column-accurate error, mirrored as a highlighted line in the editor
  • Successfully parsed input is rendered as a collapsible tree
  • Load a .json file directly or start from built-in sample data

Example

Input:

{
  "name": "DevFormats",
  "valid": true,
}

Result: SyntaxError at the line containing the closing brace, with the explanation "A trailing comma appears right before a closing } or ] — JSON does not allow a comma after the last item."

Common errors

The four patterns this tool specifically recognizes are: a trailing comma after the last item in an object or array, single quotes instead of double quotes around strings or keys, an object key written without quotes, and // or /* */ comments — none of which are legal JSON even though all four are legal (or common) in JavaScript object literals, which is where the confusion usually comes from. "Unexpected end of JSON input" means a bracket or brace was never closed — count your { } and [ ] pairs.

Best practices

Treat the explanation as a hint, not a guaranteed diagnosis — the pattern matching looks at a small window of text around the failure point, so on unusual input it can occasionally point at the wrong cause even while the line/column is exact. The tool deliberately doesn't auto-fix your JSON, since silently correcting syntax could also silently change data you didn't intend to change; fix the reported spot yourself and re-run.

Spec

RFC 8259 — The JSON Data Interchange Format

Frequently Asked Questions

How is this different from the JSON Validator?

The validator gives you a pass/fail plus structural stats. This tool goes further on failure — it recognizes the most common error patterns (trailing commas, single quotes, unquoted keys, comments) and explains what likely went wrong in plain language.

Can it fix my JSON automatically?

No — it explains the problem so you can fix it yourself, since silently "fixing" JSON risks changing your intended data.

What if my error isn't one of the common patterns?

You still get the raw line and column from the parser, even when the tool can't offer a specific explanation.

Is my JSON uploaded anywhere?

No — parsing happens entirely in your browser via the native JSON.parse.