Updated October 2026 for .NET 10 (LTS) and System.Text.Json 10.

System.Text.Json throws this error when the text it reads is not strict JSON. The usual culprits are single quotes, unquoted property names, comments or trailing commas. Some of these can be allowed with a setting; others must be fixed at the source. Here is how to find which one you have and fix it.

The error

System.Text.Json.JsonException: ''' is an invalid start of a property name. Expected a '"'. Path: $ | LineNumber: 1 | BytePositionInLine: 2.

The character in the first quotes tells you what went wrong: ''' means a single quote, a letter such as 'F' means an unquoted name, and '/' means a comment. LineNumber and BytePositionInLine point to the exact spot (both start at 0).

Why it happens

System.Text.Json follows the JSON standard (RFC 8259) strictly: property names and string values must use double quotes. Newtonsoft.Json is more forgiving, so this error often appears right after switching from Newtonsoft to System.Text.Json.

InputAllowed by System.Text.Json?Fix
{ 'name': "Ann" } (single quotes)NoFix the JSON at the source
{ name: "Ann" } (unquoted name)NoFix the JSON at the source
{ "name": "Ann" // comment }Yes, with an optionReadCommentHandling = Skip
{ "name": "Ann", } (trailing comma)Yes, with an optionAllowTrailingCommas = true

Fix 1: Send valid JSON (best fix)

Change the producer so it writes standard JSON with double quotes. Invalid:

{
  'FirstName': "Ann"
}

Valid:

{
  "FirstName": "Ann"
}

If you build JSON by hand with string concatenation, switch to JsonSerializer.Serialize(obj). It always produces valid JSON.

Fix 2: Allow comments and trailing commas

Config files and hand-edited JSON often contain comments or trailing commas. Allow them with JsonSerializerOptions:

using System.Text.Json;

var options = new JsonSerializerOptions
{
    ReadCommentHandling = JsonCommentHandling.Skip, // ignore // and /* */ comments
    AllowTrailingCommas = true                      // accept { "a": 1, }
};

var bank = JsonSerializer.Deserialize<Bank>(json, options);

public record Bank(string Name, List<Branch> Branches);
public record Branch(string Street, string Zip, string State);

Create the options object once and reuse it. Creating new options on every call is slow. More examples: Serialize and deserialize with System.Text.Json.

Fix 3: Apply the options in ASP.NET Core

If the error comes from a request body in your API, set the same options globally in Program.cs.

For controllers:

builder.Services.AddControllers()
    .AddJsonOptions(o =>
    {
        o.JsonSerializerOptions.ReadCommentHandling = JsonCommentHandling.Skip;
        o.JsonSerializerOptions.AllowTrailingCommas = true;
    });

For minimal APIs:

builder.Services.ConfigureHttpJsonOptions(o =>
{
    o.SerializerOptions.ReadCommentHandling = JsonCommentHandling.Skip;
    o.SerializerOptions.AllowTrailingCommas = true;
});

Fix 4: You cannot change the source and it uses single quotes

System.Text.Json has no option to accept single quotes or unquoted names. If a third-party system sends that format and you cannot change it, parse that one payload with Newtonsoft.Json, which accepts it:

// dotnet add package Newtonsoft.Json
using Newtonsoft.Json;

var person = JsonConvert.DeserializeObject<Person>("{ 'FirstName': 'Ann' }");

Keep System.Text.Json everywhere else. See how to add Newtonsoft.Json support in ASP.NET Core if a whole API needs it.

Not JSON at all?

If the error appears when calling another API, log the first part of the response before deserializing. You may be receiving an HTML error page, XML or plain text instead of JSON:

var body = await response.Content.ReadAsStringAsync();
logger.LogDebug("Response starts with: {Start}", body[..Math.Min(body.Length, 200)]);

response.EnsureSuccessStatusCode(); // fail fast on 4xx/5xx error pages

FAQ

Why did this work with Newtonsoft.Json?

Newtonsoft accepts several non-standard formats by default, including single quotes and unquoted names. System.Text.Json is strict by design, which makes it faster and safer.

What does “‘s’ is an invalid start of a value” mean?

It is the same problem in a value position: a string value without double quotes, or text that is not JSON at all. Check the producer, or log the raw input as shown above.

Is there a quick way to create C# classes for my JSON?

Yes. Paste valid JSON into the free C# Class Converter to get matching classes. If the tool reports an error, your JSON is invalid too.

Related

Sources: Microsoft Learn: Allow some kinds of invalid JSON · Microsoft Learn: Migrate from Newtonsoft.Json · RFC 8259