JSON error reference

Every common way JSON.parse fails, what the message is really pointing at, and the fix. Each page has a broken example and a working one you can open in the validator.

Two things make these errors harder to read than they need to be. First, the position in the message is where the parser gave up, not where you went wrong. A missing comma usually gets reported a token or two late. Second, every engine words the same failure differently, and V8 changed its own wording around Chrome 109. What used to read Unexpected token } in JSON at position 8 now reads ...is not valid JSON with a snippet. Each page below lists the wordings you are likely to see, so you can match yours.

JavaScript

Python

Java (Jackson, Gson and Spring)

PHP

Go

C# (.NET)

Not sure what JSON is yet?

Start with what is a JSON file. It covers the format, its six types, and the three mistakes behind most of the errors above. If you just need to open one, how to open a JSON file covers every platform.

The fastest way to find any of them

Paste the document into the JSON validator. It turns the parser's character offset into a line and column, highlights the spot, and repairs the mistakes that can be repaired safely. Nothing is uploaded. The parsing happens in your browser. If the document is one long line, see how the validator formats it so the mistake is easy to find.

How these pages are written

Every broken JSON example fails to parse and every fixed one parses. On the Java pages, the broken and fixed code were both run, on Jackson or on Gson, and the messages are what they printed. On the C# pages the messages are what System.Text.Json and Newtonsoft.Json printed for the sample. A test checks each one. Written by Vishnu Shankar.

What you put into the tools never leaves your browser. We count page views and keep them for 90 days. Accept and we also remember this browser, so a return visit is not counted as new. Privacy policy