What this tool does
A JSON sample becomes C# records, one per object.
{ "id": 1, "firstName": "Ada", "address": { "city": "Paris" } }
using System.Text.Json.Serialization;
public record Root(
[property: JsonPropertyName("id")] long Id,
[property: JsonPropertyName("firstName")] string FirstName,
[property: JsonPropertyName("address")] Address Address
);
public record Address(
[property: JsonPropertyName("city")] string City
);
Positional records need C# 9; the using appears only when an attribute does.
The attribute target matters
C# property names are PascalCase, so firstName becomes FirstName and content-type becomes ContentType. System.Text.Json matches names case-insensitively only if you ask it to, and never across a dash — so the key is pinned with an attribute.
The property: prefix is the part that is easy to get wrong. On a positional record, the parameter is not the property: an attribute without a target sits on the constructor parameter and the serializer never sees it. With the target it lands where it is read.
Types
- Integers become
long, decimalsdouble— both wider than the 32-bit default, because a JSON number does not promise to fit in one. nulland unknown values becomeobject?, which needs nullable reference types enabled (the default since .NET 6).- Arrays become
List<T>; a mixed array becomesList<object>, except when it mixes integers and decimals, whereList<double>covers both. - A scalar at the root is refused: C# has no global type alias, so
42has nothing to become. An array of objects gives you the record of its element, which is what you bind to aList<Root>.
What a sample cannot say
No property is nullable beyond those object?, and none has a default: the document had a value for each. required and init are worth adding once you know which keys are truly mandatory — a sample can only tell you which ones happened to be there.
Private by design
Everything runs locally in your browser with JavaScript. Your data is never uploaded, which makes the tool safe for sensitive content, and it keeps working offline.