Unexpected character encountered while parsing value 🟪 .NET

Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 0, position 0

Json.NET was given text that isn’t valid JSON — commonly HTML, a BOM, or an already-serialized string.

Seen on: .NET

Meaning

Same root causes as other JSON parse errors: HTML/error responses, double-serialized JSON (a JSON string containing JSON), or a file starting with a BOM/invalid character.

Common causes

  • HTML or error page instead of JSON
  • Double-serialized JSON (string wrapping JSON)
  • Invalid characters/BOM at start
  • Truncated responses

⚡ Quick fix

  1. Log the raw text before parsing
  2. Deserialize once (avoid JsonConvert.SerializeObject on an existing JSON string)
  3. Check status codes first

Detailed fix by platform

C#

  1. csharp
    var raw = await res.Content.ReadAsStringAsync();
    logger.LogDebug("Raw: {Raw}", raw);
    var obj = JsonConvert.DeserializeObject<Order>(raw);

How to diagnose

  1. Raw — First characters
  2. Serialization — Done twice?

🔧 Still not fixed?

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

🧠 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.