JSON to C# Class
Generate C# classes from JSON with [JsonPropertyName] attributes for the modern System.Text.Json serializer. For Newtonsoft.Json, swap to [JsonProperty] and add using Newtonsoft.Json;.
How to use the JSON to C# Class
Paste JSON. Output uses System.Text.Json (the default in modern .NET 6+). For records, you can collapse the property syntax to public record Response(string Id, string Name); manually.
Generating C# classes from JSON
When you consume an API in C# you want strongly-typed classes, not JsonElement lookups and string keys scattered through your code. But hand-writing those classes from a sample response — getting every property name, type, and serializer attribute right — is dull and easy to get subtly wrong.
This generates C# classes from a JSON sample, annotated with [JsonPropertyName] for the modern System.Text.Json serializer that ships with .NET 6 and later, nesting a class for each nested object. If your project still uses Newtonsoft.Json, switch the attributes to [JsonProperty]; for the equivalent on other platforms, the Java, Go, and Rust generators follow the same idea.
Common use cases
- Type an API client — turn a sample response into C# model classes.
- System.Text.Json — get
[JsonPropertyName]attributes for the modern serializer. - Nested models — generate a class per nested object automatically.
- Scaffold DTOs — create data-transfer objects without a schema.
- Records — start from generated classes and collapse to a record where it fits.