The JSON value could not be converted .NET Origin: Application & API Last updated 14 Oct 2026

System.Text.Json.JsonException: The JSON value could not be converted to System.Int32. Path: $.id

System.Text.Json couldn’t map a JSON value to the target .NET type — e.g. "42" (string) to int, null to a non-nullable type, or wrong enum value.

Exact message you may see The JSON value could not be converted toPath: $ | LineNumber
Seen on: .NET

Meaning

System.Text.Json is stricter than Newtonsoft: numbers in strings, case differences, enums as strings and comments are rejected unless configured.

Common causes

  • Number sent as a string
  • Enum sent as text without JsonStringEnumConverter
  • null into a non-nullable value type
  • Property type differs from the JSON shape (object vs array)

⚡ Quick fix

  1. Enable NumberHandling = AllowReadingFromString
  2. Add JsonStringEnumConverter
  3. Fix the DTO type or make it nullable

Detailed fix by platform

C#

  1. csharp
    builder.Services.ConfigureHttpJsonOptions(o => {
        o.SerializerOptions.NumberHandling = JsonNumberHandling.AllowReadingFromString;
        o.SerializerOptions.Converters.Add(new JsonStringEnumConverter());
    });

How to diagnose

  1. Path — $.path in the message
  2. JSON — Actual value
  3. Options — Serializer settings

🔧 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: Application & API. Errors that are often confused with or caused by this one (click to open):

circular JSON — TypeError: Converting circular structure to JSON (JavaScript)circular JSONDecodingError — Swift DecodingError: keyNotFound / typeMismatch / valueNotFound / dataCorrupted (iOS)DecodingErrorEJSONPARSE — npm ERR! code EJSONPARSE — Failed to parse json / Unexpected token in JSON at position (npm)EJSONPARSEentity.parse.failed — API Error: Malformed JSON in request body (entity.parse.failed / JSON parse error) (API)entity.parse.failedHttpMessageNotReadableException — HttpMessageNotReadableException: JSON parse error / Required request body is missing (Java)HttpMessageNotReadabl…invalid_type — API Error: Invalid type — expected integer, received string (API)invalid_typeInvalidDefinitionException — com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class X and no properties discovered (Java)InvalidDefinitionExce…is an invalid start of a value — System.Text.Json: '<' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0 (.NET)is an invalid start o…The JSON …

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.