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

Type mapping rules

JSON valueC# type
42int
3.14double
"hello"string
true / falsebool
nullobject
[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.