You deserialize a JSON body in .NET and get The JSON value could not be converted to System.String, with a Path pointing at one property. The cause is almost always a type mismatch: the JSON has a number, a boolean or an object where your C# property is a string, and System.Text.Json does not convert between types on its own. There are three fixes: change the C# type to match, add a small converter that accepts numbers and booleans as text, or keep Newtonsoft.Json for that API. All three are below, with the output I got on .NET 10.

- Why the JSON value could not be converted to System.String
- Same error for List, DateTime and nullable types
- Fix 1: match the C# type to the JSON
- Fix 2: accept numbers and booleans as strings with a converter
- Fix 3: keep Newtonsoft.Json for that API
- How to find the failing property fast
- What was tested and what was not
- Summary
- System.String conversion FAQ
Why the JSON value could not be converted to System.String
This JSON sends a number and a boolean:
The class declares both as strings, so deserializing throws:
public class Customer
{
public string FirstName { get; set; } = "";
public string EmployeeId { get; set; } = ""; // JSON has a number
public string IsPermanent { get; set; } = ""; // JSON has true/false
}
var customer = JsonSerializer.Deserialize<Customer>(json); // JsonException
Newtonsoft.Json quietly turns 1042 into "1042". I confirmed that on Newtonsoft.Json 13.0.3, which is why this error often appears right after a move to System.Text.Json. A null is fine: "Name": null deserializes to a null string without error.
Same error for List, DateTime and nullable types
The message is the same for other target types, and the Path tells you which property failed. These are the real messages from my test run on .NET 10, with the cause of each:
| Message ends with | JSON that caused it | Fix |
|---|---|---|
System.String | number, boolean or object where a string is expected | match the type, or use a converter |
System.Collections.Generic.List`1[System.String] | {"Tags":{"a":1}} (an object instead of an array) | change the JSON to [ ] or change the C# type |
System.DateTime | "21/10/2026" (not ISO 8601) | send 2026-10-21 or write a date converter |
System.Nullable`1[System.Int32] | {"Count":"abc"} (text where a number is expected) | fix the data, or accept quoted numbers (see the FAQ) |
Read the full message from the top: the part after “converted to” is the type your C# property has, not the type in the JSON.
Fix 1: match the C# type to the JSON
If EmployeeId is always a number, make it a number. This is the cleanest fix because you keep real types:
public class Customer
{
public string FirstName { get; set; } = "";
public int EmployeeId { get; set; }
public bool IsPermanent { get; set; }
}
I ran this class against the JSON above and it deserialized to {"FirstName":"Ann","EmployeeId":1042,"IsPermanent":true}.
Fix 2: accept numbers and booleans as strings with a converter
If the sender is inconsistent (sometimes "1042", sometimes 1042) and the property must stay a string, add a converter. This one keeps the exact digits of a number instead of reformatting it:
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
public sealed class FlexibleStringConverter : JsonConverter<string>
{
public override string? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) =>
reader.TokenType switch
{
JsonTokenType.String => reader.GetString(),
JsonTokenType.Number => Encoding.UTF8.GetString(reader.ValueSpan), // keeps the exact digits
JsonTokenType.True => "true",
JsonTokenType.False => "false",
JsonTokenType.Null => null,
_ => throw new JsonException($"Cannot read {reader.TokenType} as a string.")
};
public override void Write(Utf8JsonWriter writer, string value, JsonSerializerOptions options) =>
writer.WriteStringValue(value);
}
Apply it to one property with an attribute, or to every string through the options:
[JsonConverter(typeof(FlexibleStringConverter))]
public string EmployeeId { get; set; } = "";
// or for all string properties
var options = new JsonSerializerOptions();
options.Converters.Add(new FlexibleStringConverter());
var customer = JsonSerializer.Deserialize<Customer>(json, options);
Results from my run: the number 1042 became "1042", true became "true", 12345678901234567890.50 stayed exactly "12345678901234567890.50", and an object such as {"x":1} was still rejected with my own message Cannot read StartObject as a string. That last part is intended: the converter only relaxes numbers and booleans.
Register it once in ASP.NET Core
// Controllers
builder.Services.AddControllers()
.AddJsonOptions(o => o.JsonSerializerOptions.Converters.Add(new FlexibleStringConverter()));
// Minimal APIs
builder.Services.ConfigureHttpJsonOptions(o =>
o.SerializerOptions.Converters.Add(new FlexibleStringConverter()));
I ran a minimal API with a Customer(string FirstName, string EmployeeId) record and posted {"firstName":"Ann","employeeId":1042}. Without the converter the endpoint answered 400 and logged The JSON value could not be converted to Customer. Path: $.employeeId. With it, the response was {"firstName":"Ann","employeeId":"1042"}. For more on writing converters see creating a string converter for System.Text.Json and Write custom converters (Microsoft Learn).
Fix 3: keep Newtonsoft.Json for that API
If you are migrating a large API that depends on Newtonsoft’s loose conversions, you can keep it while you fix the types gradually:
// dotnet add package Microsoft.AspNetCore.Mvc.NewtonsoftJson
builder.Services.AddControllers().AddNewtonsoftJson();
This compiled on .NET 10 with package version 10.0.0. See adding Newtonsoft.Json support in ASP.NET Core and the Migrate from Newtonsoft.Json (Microsoft Learn). For new code, prefer Fix 1.
How to find the failing property fast
- Read
Pathin the message, for example$.Address.ZipCode. It includes nested properties and array indexes. - Compare that JSON value with the C# property type, not with the class name in the message.
- Log the raw request body in a test environment only, and never log secrets or personal data.
- Related: the same error for System.Int32 and serialize and deserialize with System.Text.Json.
What was tested and what was not
- Run on .NET SDK 10.0.401: every message in the table, the matching-types fix, the converter on options, the converter in a minimal API (HTTP 200 and 400 checked with curl), and Newtonsoft.Json 13.0.3 behaviour.
- Compiled only: the
AddControllers().AddJsonOptionsregistration andAddNewtonsoftJson(). - Not tested: older runtimes than .NET 10, and a custom DateTime converter (only the ISO 8601 fix was checked).
Summary
- The error means the JSON value type does not fit the C# property type, and System.Text.Json will not convert it for you.
- Best fix: change the C# type to match. If the sender is inconsistent, add a converter that accepts numbers and booleans as text.
- Use
Pathin the message to find the property, and read the text after “converted to” to see the target type.
Found this useful?
Bookmark this page and share it with your team. Get new .NET, cloud and database tutorials in your inbox.
System.String conversion FAQ
Is there a built-in option to read numbers into strings?
No. JsonNumberHandling.AllowReadingFromString works the other way: it lets a quoted number such as "42" fill an int property. I tested it, and it still throws for a number going into a string property. Use a converter for that.
Why does the same error mention List or Nullable?
The text after “converted to” is the C# target type. For List`1 the JSON had an object where an array was expected, and for Nullable`1[System.Int32] it had text where a number was expected.
How do I find which property caused the error?
Read the Path part of the message, for example $.Address.ZipCode. It points at the exact JSON property, including nested ones.
Did one of these fixes solve your case? Tell us in the comments which JSON value caused it.

Useful post; thank you. In my case, I’m moving away from Newtonsoft because using it generates an error on a build server (“Package Newtonsoft.Json 13.0.1 is not compatible with…”).
Thanks Neil, Glad you found article useful…
I had similar issues. Newtonsoft worked fine but I decided to upgrade. Ran into so much issues that I reverted back to Newton. You can as you mention write your own custom converter but that I believe hits a lot harder to maintainability that it’s not worth it.
Hey Tomas, Thanks for your comments.
I agree with you. It’s a bit tough when trying to move away from Newtonsoft. You can very much take a calculated attempt on using it. I would say try an approach of strangulation where you move out of old by replacing it with a simple converter as and when required. Again decisions would more rely on a few factors like a performance? maintenance? security? etc.