JSON to C# Class
Paste a sample JSON object below and generate C# classes with `{ get; set; }` properties. The tool infers a type for every field and creates a named class for each nested object.
Runs entirely in your browser — your JSON is never uploaded to a server. No ads injected into the output, no sign-up. Emits idiomatic PascalCase properties that System.Text.Json binds without extra attributes.
How to generate a C# class from JSON
- Paste your JSON. Paste one representative JSON object into the box above.
- Generate the class. Click Generate C# class. The tool infers a type for every field and emits a class with auto-properties for the root and each nested object.
- Deserialize. Copy the classes into your project and use System.Text.Json or Newtonsoft.Json to deserialize the payload.
How the type mapping works
Each JSON value maps to a C# type: a whole number becomes long, a decimal becomes double, a string becomes string, true/false becomes bool, and null becomes object. Arrays become List<T>. Property names are PascalCased to match C# conventions.
Arrays and nested objects
An array becomes a typed collection using the type of its first element, and every nested object gets its own named type so the result compiles as-is. Works with System.Text.Json and Newtonsoft.Json. Property names are PascalCased; add [JsonPropertyName] if your keys differ.
Using the result
Deserialize with System.Text.Json: JsonSerializer.Deserialize<Root>(json) (it matches property names case-insensitively by default).
FAQ
Will the PascalCase names still bind to camelCase JSON?
System.Text.Json matches case-insensitively by default, and Newtonsoft matches loosely too, so Name binds to "name". If a key can't be expressed as an identifier, add a [JsonPropertyName("...")] attribute.
Why long instead of int?
JSON has one number type, so the tool picks long for whole numbers to avoid overflow on large ids and double for decimals. Narrow to int or decimal where the range is known.
Records or classes?
This emits classes with mutable auto-properties, which is what most serializers and frameworks expect. Convert to a record if you want immutability.