JSON to C# Class Generator
Generate C# classes or records from a JSON sample, with PascalCase properties, JsonPropertyName attributes and nullable types for missing values.
Free · No sign-up · Your inputs stay in your browser
Input
Generate C# types from JSON
Output
C#
1,093 characters
Written for System.Text.Json: each property carries [JsonPropertyName] with the original key, so PascalCase names still bind. Nullable value types (long?, bool?) mark keys that are null or missing in the sample; enable <Nullable> in the project for the reference types. Types come from this one sample: give fields that are null here a real value to type them.
Runs in this browser. Nothing you paste is sent to a server.
About this tool
Method, assumptions, practical next steps, and limits.
System.Text.Json conventions
The attributes target System.Text.Json, the serializer built into .NET. Because every property names its JSON key explicitly, the output works whatever JsonSerializerOptions.PropertyNamingPolicy is set to. Newtonsoft.Json users can swap the attribute for [JsonProperty("...")].
Nullable reference types
Value types such as long and bool are marked with ? when the sample shows them null or missing. Reference types such as string and List are only checked by the compiler when <Nullable>enable</Nullable> is on in the project, which is the default in new .NET templates.