Input — paste anything

Fix "Unexpected Token < in JSON at Position 0" — API Returned HTML

This error almost always means your code expected JSON but received an HTML page instead — a 404 error page, a login redirect, a 500 server error, or a proxy response. The < is the first character of the HTML <!DOCTYPE> or <html> tag. JSONBlitz can extract any JSON that may be embedded in the response — paste the full HTML below and it will find it.

⚡ Auto-fixed issues see changes ↓
Ready — paste JSON or any text containing JSON
🌳
Tree view appears here after processing
Click nodes to copy JSONPath • Single-click a leaf to copy value
Formatted output appears here...
Process JSON to generate code...
Insights appear after processing
Shows what JSONBlitz changed to fix your JSON. Process some broken JSON first.
No changes recorded yet.
⌘↵ fix & copy   ⌘⇧V paste & fix   ⌘K actions   click copy value   dblclick copy path © 2026 JSONBlitz

Fix "Unexpected Token < in JSON at Position 0" — Your API Returned HTML

"Unexpected token < in JSON at position 0" is the most searched JSON error. It means JSON.parse() or response.json() received an HTML document instead of JSON. The "<" character is position 0 of <!DOCTYPE html> or <html>. This is not a JSON formatting problem — the server returned the wrong content type entirely.

Common Causes

A 404 Not Found page returned when the API endpoint URL is wrong. A 401 or 403 page when authentication is missing or expired. A 500 Internal Server Error page when the backend crashed. A login redirect page when a session expired. A CDN or proxy returning a cached HTML error. In each case the server is telling you something went wrong — it just did it in HTML rather than JSON.

How to Diagnose

Open your browser DevTools Network tab, find the API request, and look at the Response tab. If you see HTML there, the problem is the server response — not your JSON parsing code. Check the HTTP status code: 200 with HTML content means your endpoint URL may be wrong or your routing is broken. 4xx or 5xx status codes tell you the specific error type.

What JSONBlitz Can Do

If the HTML response contains embedded JSON — in a script tag, a data attribute, a comment, or inline — JSONBlitz will extract it. Paste the full response below. If the HTML contains no JSON, JSONBlitz will tell you clearly so you know the problem is upstream in your API.

Frequently Asked Questions

Why does "unexpected token <" happen?
Your code called JSON.parse() or response.json() on an HTML document. The first character of HTML is "<" (from or ), which is not valid JSON.
How do I fix it in my code?
Check the HTTP status code before parsing: if (!response.ok) throw new Error(response.status). Add Content-Type header checking: if (!response.headers.get("content-type")?.includes("application/json")) — do not parse. Fix the underlying API issue causing the HTML response.
Can JSONBlitz recover my JSON from the HTML?
If the HTML response contains embedded JSON — in a script tag, data attribute, or anywhere in the markup — JSONBlitz will extract it. If the response is a pure error page with no JSON, the original JSON data was never sent and cannot be recovered.
Recent Sessions