Http failure during parsing Angular Origin: On your device Last updated 15 Oct 2026

Angular: Http failure during parsing for http://…: SyntaxError: Unexpected token '<' (response is not JSON)

The request succeeded (status 200) but the body could not be parsed as the expected type — usually HTML or plain text instead of JSON.

Exact message you may see Http failure during parsing forSyntaxError: Unexpected token '<' in JSON at position 0 Http failure during parsingHttp failure during parsing for http://localhost:4200/apiHttpErrorResponse Http failure during parsingUnexpected token < in JSON
Seen on: Angular TypeScript

Meaning

HttpClient parses responses as JSON by default. If the server returns an HTML page (proxy error, login redirect, SPA fallback) or plain text, parsing fails with Http failure during parsing. Use responseType: 'text' for text endpoints, or fix the URL so the API returns JSON.

Common causes

  • The URL returns HTML (the SPA index.html or an error page)
  • Endpoint returns plain text or an empty body with a JSON default
  • Wrong Accept header or response type
  • API returns invalid JSON (trailing comma, BOM)
  • Proxy/redirect to a login page

⚡ Quick fix

  1. Open the URL in the browser or curl and check the body
  2. Set responseType: 'text' (or 'blob') where JSON is not returned
  3. Fix the endpoint or proxy path so it returns JSON

Detailed fix by platform

Angular

  1. this.http.get(url, { responseType: 'text' }) for text responses
  2. Debug: curl -i -H "Accept: application/json" https://api.example.com/x

Code examples

Plain text endpoint

typescript
this.http.get('/api/version', { responseType: 'text' }).subscribe(v => console.log(v));   // "1.4.2"

How to diagnose

  1. Body — What does curl return?
  2. Type — JSON or text?
  3. Path — Is a proxy returning HTML?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

entity.parse.failed — API Error: Malformed JSON in request body (entity.parse.failed / JSON parse error) (API)entity.parse.failedexceeded maximum budget — Angular build: Error: bundle initial exceeded maximum budget. Budget 1.00 MB was not met by 120.00 kB with a total of 1.12 MB (Angular)exceeded maximum budg…Http failure response for (unknown url): 0 Unknown Error — Angular: HttpErrorResponse — Http failure response for (unknown url): 0 Unknown Error (status 0) (Angular)Http failure response…Http failure response: 404 Not Found — Angular: Http failure response for http://…/api/x: 404 Not Found (HttpErrorResponse) (Angular)Http failure response…NullInjectorError: No provider for HttpClient! — Angular: NullInjectorError: No provider for HttpClient! — provideHttpClient() missing (Angular)NullInjectorError: No…Schema validation failed with the following errors — Angular CLI: Schema validation failed with the following errors: Data path "" must NOT have additional properties(xyz) (Angular)Schema validation fai…Unexpected token < — SyntaxError: Unexpected token '<' (HTML served instead of JavaScript) (JavaScript)Unexpected token <Http fail…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.