JSON to C# Class Generator
Paste JSON and get C# classes with typed properties, nested types and lists — annotated for System.Text.Json or Newtonsoft.Json, so keys like order_number map to OrderNumber.
Runs entirely in your browser — nothing you enter here is sent to a server.
From a JSON sample to C# classes
To work with a JSON API in .NET you describe its shape as classes and let the serializer do the rest. Writing those classes by hand for a response with a dozen nested objects is slow and error-prone. Paste one real response here and the generator writes them: a class per object, a property per key, a type inferred from each value.
Property types
string, int or long, double, bool, a nested class, or List<T>. A value that was null in the sample becomes object.
PascalCase names
Keys are converted to .NET naming — unit_price to UnitPrice — and an attribute records the original key so that serialization round-trips.
Optional values
A property missing from some array elements becomes nullable: bool?, int?.
Your serializer
[JsonPropertyName] for System.Text.Json, [JsonProperty] for Newtonsoft.Json, or no attributes if you configure a naming policy instead.
Finishing touches
The generated code compiles as it stands, but a sample cannot tell you everything. Change date strings to DateTimeOffset — both serializers parse ISO 8601 automatically. Use decimal rather than double for money. If nullable reference types are enabled in your project, mark properties that may be absent with ? or give the others a required modifier. And with System.Text.Json you can drop the attributes altogether by setting PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower (available from .NET 8).
Frequently asked questions
How do I deserialize JSON into the generated classes?
With System.Text.Json: var value = JsonSerializer.Deserialize<Root>(json); With Newtonsoft.Json: var value = JsonConvert.DeserializeObject<Root>(json);
Should I use System.Text.Json or Newtonsoft.Json?
System.Text.Json is built into modern .NET and is faster; choose it for new projects. Newtonsoft.Json has more features and is the usual choice in older codebases.
Why is a property typed as object?
Its value was null in the sample, so the type could not be inferred. Replace it with the real type once you know it.
Can it generate records instead of classes?
Not directly, but the properties translate one to one: change "class" to "record" and "set" to "init".