Why use this generator
JsonProperty attributes
Every field gets a [JsonProperty("name")] attribute for Newtonsoft.Json compatibility. The C# property name is PascalCase; the JSON name is preserved.
Type mapping
JSON strings become string, integers become long, floats become double, booleans become bool, null becomes object. Arrays become List<T>.
Nested classes
Each nested object becomes its own class. Class names are derived from field names, PascalCase by convention.
Conversion explained
1. Parse JSON
Input is parsed into a JavaScript value. The class structure is determined by walking the value tree.
2. Collect classes
For each object, a C# class is generated with auto-properties and JsonProperty attributes. The class name is derived from the parent field name, PascalCased.
3. Emit C#
Classes are emitted with proper C# formatting: 4-space indentation, auto-properties, and Newtonsoft.Json attributes.
JSON to C# Class Generator — frequently asked questions
Which JSON libraries are supported?
The output uses [JsonProperty] from Newtonsoft.Json (Json.NET). For System.Text.Json, replace with [JsonPropertyName("name")] and update the using directive.
Why use long instead of int?
JSON integers can be very large (JavaScript numbers go up to 2^53). long (64-bit) handles all possible JSON integers safely.
Are nullable types supported?
Currently, nullable fields use object. For proper nullable typing, edit the output to use T? (e.g., int?, string?).
How are nested objects handled?
Each nested object becomes its own class, with the class name derived from the parent field name (PascalCase).
You might also like
JSON to Java
Generate Java POJO classes from JSON
JSON to Python
Generate Python dataclasses from JSON
JSON to Go
Generate Go structs from JSON
JSON to Kotlin
Generate Kotlin data classes from JSON
JSON to TypeScript
Generate TypeScript interfaces from JSON
JSON Validator
Validate JSON syntax with detailed error messages