JSON error lookup
Paste the error message your code printed. If you also paste the JSON it was parsing, the lookup marks the place where parsing failed. It works with messages from Chrome, Edge, Node.js, Firefox, Safari, Python, Go, PHP and Rust.
Everything is checked in your browser. Nothing you paste here is sent anywhere.
Getting the text your code parsed
Many JSON errors are easy to understand once you see the text that was actually parsed, because it often isn’t what you expected, such as an HTML error page or an empty body. Log the start of it right before the parse call, then paste that here along with the error.
In JavaScript with fetch:
const res = await fetch(url);
const text = await res.text();
console.log(res.status, text.slice(0, 500));
const data = JSON.parse(text);In Python with requests:
r = requests.get(url)
print(r.status_code, r.text[:500])
data = r.json()In Go:
body, err := io.ReadAll(resp.Body)
if err != nil {
return err
}
log.Printf("%d %.500s", resp.StatusCode, body)
err = json.Unmarshal(body, &data)In PHP:
var_dump(substr($json, 0, 500));
$data = json_decode($json, true, 512, JSON_THROW_ON_ERROR);The JavaScript, Python and Go versions print the status code too, because a 404, 401 or 500 often explains the error on its own.
Reading the position in the message
Most messages say where the parser stopped, but they don’t all count the same way. Take this JSON, where the comma after 7 is missing:
{"id": 7 "name": "Maya"}| Language | What the message says | Counts |
|---|---|---|
| Chrome, Edge, Node.js | at position 9 (line 1 column 10) | Position from 0, line and column from 1 |
| Python | line 1 column 10 (char 9) | char from 0, line and column from 1 |
| Firefox | at line 1 column 10 | From 1 |
| Rust (serde_json) | at line 1 column 10 | From 1, and the column counts bytes |
| Go, PHP, Safari | No position | Paste the JSON to find it |
The ones that give a position all point at the " before name, which is where the parser noticed something was wrong. The actual mistake is usually just before that spot. If your editor shows column numbers, the line and column will match it, but Chrome’s “position 9” is the tenth character, since it starts at 0.
The numbers can drift apart when the text has emoji or accented letters in it. Chrome counts each emoji as two characters and Rust counts bytes, so the same spot can get three different numbers. The lookup converts each of them for you.
Each result links to a guide with more detail on that error. You can also browse the full list of JSON errors.