JSON to C# Class
Generate C# classes with Newtonsoft.Json attributes from a JSON sample. Handles nested classes, collections, and null fields. Runs entirely in your browser.
Input JSON
How it works
- Paste any valid JSON — classes are inferred from the values: numbers, strings, booleans, arrays, and nested objects.
- Whole numbers become
int, decimals becomedouble, andnullbecomesobject. - Arrays become
List<T>; arrays of objects becomeList<Type>. - Every property gets a
[JsonProperty("...")]attribute so Newtonsoft.Json maps the original key exactly.
Type mapping rules
| JSON value | C# type |
|---|---|
42 | int |
3.14 | double |
"hello" | string |
true / false | bool |
null | object |
[1, 2, 3] | List<int> |
[{...}, {...}] | List<Type> |
{"a": 1} | class |
About JSON to C# Class
Deserializing JSON in .NET usually means writing POCO classes first, and hand-typing them for a large API response wastes time and invites typos. This tool generates plain C# classes from a JSON sample, complete with [JsonProperty] attributes so property names map back to the original keys — handy when the JSON uses snake_case, kebab-case, or abbreviations that differ from idiomatic C# property names. Nested objects become nested classes and arrays become List<T>.
The output mirrors only what the sample shows: fields missing from the sample are absent from the class, and fields that appear as null become object. After generating, review the result and make value types nullable (int?) where a field can legitimately be absent, or switch to System.Text.Json by replacing the attributes with [JsonPropertyName]. Everything runs on your device, so private payloads stay private.