# JSON parse error: what it means and how to fix it

Source: https://checkcraft.ru/en/guides/json-parse-error.html · updated 2026-11-24

What JSON parse error and similar messages mean: Unexpected token, Unexpected end of JSON input, The document is empty, Failed to parse JSON.

Practical workflow

Checkcraft is a desktop app for checking APIs and logs without code, with a free edition. [Download, no sign-up →](https://checkcraft.ru/en/download-checkcraft.html#free-download)

A JSON parse error means a program received text that was supposed to be JSON and could not read it. There are three kinds of causes: the text is empty, it is not JSON at all (often an HTML page), or the JSON has a syntax error. Below is how to tell which one you have and what to do.

Checkcraft · 24 November 2026

Get help with your first test →

## What JSON parse error means

Parse means read and convert. The program reads the text character by character and builds an object. As soon as it meets something JSON cannot contain, parsing stops with an error. The message usually includes the position or line where it happened, and that is the main clue.

## Three kinds of causes

Empty text: the server returned nothing or the file is empty, hence The document is empty and Unexpected end of JSON input. Not JSON: an HTML error or login page arrived, hence Unexpected token with a less-than sign at the start. Broken JSON: single quotes, a trailing comma, a comment, a truncated response.

Checked one response? Save the rule in Checkcraft and it works on every next one. [Download Free →](https://checkcraft.ru/en/download-checkcraft.html#free-download)

## If someone else's app shows the error

If you see a JSON parse error in an app, a game or a website rather than your own code, the service usually returned an empty response or an error page. Retry later, check your connection and VPN, update the app, and for desktop programs delete the corrupted settings file so the program recreates it.

## How to avoid it in your code

Check the status code and content type before parsing, handle an empty body separately and put the start of the received text into the error message. Instead of a cryptic JSON parse error, the log then shows that a 502 page or an empty response arrived.

## How the error looks in different languages

| Where | Message | Usually means |
|---|---|---|
| JavaScript | Unexpected token < in JSON at position 0 | HTML arrived instead of JSON |
| JavaScript | Unexpected end of JSON input | Empty or truncated response |
| Python | JSONDecodeError: Expecting value: line 1 column 1 | Empty or not JSON from the first character |
| Java, Jackson | JsonParseException: Unexpected character | An invalid character in the text |
| 1C | Unexpected character when reading JSON | HTML, BOM or empty body |
| Apps | The document is empty, Failed to parse JSON config | Empty response or corrupted settings file |

Specific cases: [Unexpected token](https://checkcraft.ru/en/guides/json-unexpected-token.html), [Unexpected end of JSON input](https://checkcraft.ru/en/guides/json-unexpected-end.html), [DOCTYPE is not valid JSON](https://checkcraft.ru/en/guides/json-doctype-not-valid.html), [the 1C error](https://checkcraft.ru/en/guides/1c-json-unexpected-character.html).

## How to find the spot

1. Look at the position or line and column in the message; the mistake is usually just left of it.
2. Paste the text into a [JSON validator](https://checkcraft.ru/en/guides/json-validator-online.html): it shows the spot and the likely cause.
3. If the first character is <, it is HTML: check the status code and the request URL, not the JSON.
4. If the text is empty, there is nothing to parse: find out why the service or file returned nothing.

## Protecting your code

```
const res = await fetch(url);
const text = await res.text();
if (!text.trim()) throw new Error(`Empty response, status ${res.status}`);
try {
  return JSON.parse(text);
} catch (e) {
  throw new Error(`JSON parse error: ${e.message}. Status ${res.status}, start: ${text.slice(0, 200)}`);
}
```

Such a handler turns a cryptic parse error into a message with the status code and the start of the text. The cause is visible at a glance.

## More on JSON

Section overview and all guides: [JSON: what the format is, syntax rules, examples and common errors](https://checkcraft.ru/en/guides/json-format-guide.html).

- [Unexpected token is not valid JSON: what it means and how to find it](https://checkcraft.ru/en/guides/json-unexpected-token.html)
- [Unexpected end of JSON input: why the JSON ends early](https://checkcraft.ru/en/guides/json-unexpected-end.html)
- [Unexpected token <, <!DOCTYPE is not valid JSON: the server returned HTML](https://checkcraft.ru/en/guides/json-doctype-not-valid.html)
- [Online JSON validator that explains the error](https://checkcraft.ru/en/guides/json-validator-online.html)
- [Format JSON online: pretty print, minify and sort keys](https://checkcraft.ru/en/guides/json-formatter-online.html)

Next step

## Repeat this on your own API

Checkcraft is a desktop app that saves API response checks without code and shows what did not match. Start with a sample, then use your own sanitized data. Free runs on Windows and Linux with no time limit.

[Download Free](https://checkcraft.ru/en/download-checkcraft.html#free-download) · [Download and first run](https://checkcraft.ru/en/download-checkcraft.html)

No sign-up or email needed, the archive is ready in a couple of minutes. See the [edition limits](https://checkcraft.ru/en/pricing.html).

## References

[RFC 8259: the JSON format](https://www.rfc-editor.org/rfc/rfc8259) · [MDN: JSON.parse](https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse)

## Continue with a related task

[Unexpected token is not valid JSON: what it means and how to find it](https://checkcraft.ru/en/guides/json-unexpected-token.html) · [Unexpected end of JSON input: why the JSON ends early](https://checkcraft.ru/en/guides/json-unexpected-end.html) · [Unexpected token <, <!DOCTYPE is not valid JSON: the server returned HTML](https://checkcraft.ru/en/guides/json-doctype-not-valid.html) · [Online JSON validator that explains the error](https://checkcraft.ru/en/guides/json-validator-online.html) · [Unexpected character when reading JSON in 1C: causes and fixes](https://checkcraft.ru/en/guides/1c-json-unexpected-character.html)

Start with the linked example and compare its result with your own test requirement.

Ask a person

## Get help with your first test

Tell us what you want to test or where you got stuck. We can help you start Checkcraft, choose an example and understand your first run. You can ask before downloading.

[Ask in Telegram](https://t.me/checkcraftchat)Send an email

The Telegram group is public: do not post passwords, tokens or confidential work data. A description of your task is enough to start.

You can also email us support@checkcraft.ru

Page card: /ai/pages/en/guides/json-parse-error.md
