Turn a JSON sample into C# classes or records for System.Text.Json or Newtonsoft.Json
Runs in your browser. Nothing you type is sent anywhere. Checked against sources on 16 Oct 2026.Paste a JSON sample and get C# classes or records with PascalCase properties and the JSON key in a JsonPropertyName or JsonProperty attribute. Whole numbers become int, long past 2,147,483,647, any decimal makes a field double, and a value that is null or missing becomes nullable, such as int?.
Paste a JSON sample, such as an API response, into the left box.
The C# classes appear as you type, one per object, with PascalCase properties and the JSON key in an attribute on each.
Choose System.Text.Json or Newtonsoft.Json, and records with init if you prefer immutable models.
Press Copy, or Download to save Models.cs, and deserialize into the root class.
C# reads JSON into typed classes, and each property needs the right type and a way to find its key. This converter writes those classes from a sample, so a long API response becomes a compiling model in one paste.
How types are chosen.
| JSON value | C# type |
|---|---|
| "text" | string |
| true / false | bool |
| 42 (whole numbers only) | int, or long beyond 32 bits |
| 4.5 (any decimal seen) | double |
| null, and also a type | int?, string? |
| only null, or mixed kinds | object? |
| [ ... ] | List<...> |
| { } empty | Dictionary<string, object> |
| { ... } | a class of its own |
Keys and names. Properties are PascalCase, so user_name becomes UserName and avatar_url AvatarUrl. Every property carries its original key in an attribute, because System.Text.Json matches names case-sensitively unless told otherwise; Newtonsoft gets [JsonProperty] instead. A property that would share its class's name, which the compiler rejects as CS0542, gets Value added.
Arrays of objects. All the objects of an array are merged into one class, so a key that appears in only some of them is still there, made nullable so that its absence reads as null rather than 0 or false. Two objects with exactly the same keys and types share one class.
Options. Records with init give immutable models that compare by value. The root class is called Root unless you name it. When the JSON itself is an array or a single value, a comment says which type to deserialize into, such as List.
Every output was checked by reading the C# back and matching 9 samples against it with the serializers' rules. Nothing you paste leaves the browser.
Paste a JSON sample into the converter and the C# classes appear beside it, one per object, with a JsonPropertyName attribute on every property. Copy them into your project and read the JSON with JsonSerializer.Deserialize<Root>(json), or JsonConvert.DeserializeObject<Root>(json) when Newtonsoft is chosen.
System.Text.Json matches property names case-sensitively by default, so a property called UserName would never receive the key user_name. The attribute names the exact key, which keeps C# naming in PascalCase and still reads the JSON without any serializer options or naming policy.
A property is nullable when the sample shows null for it, or when some objects of an array leave its key out. Without the question mark, a missing number would quietly read as 0 and a missing flag as false, so the nullable type keeps absent and zero apart.
Records with init accessors suit models you only read, because their properties cannot change after deserialization and two records with the same values compare equal. Classes with set suit models you fill in or edit. Both work with System.Text.Json from .NET 5 and with Newtonsoft.Json.
Whole numbers become int, or long when a value is beyond 2,147,483,647, and a field becomes double as soon as any sample value has a decimal part. Values of different kinds, such as a number in one item and text in another, become object?, which keeps the raw JSON value.
No. The conversion runs in your browser with no request to any server, and the JSON is not stored, so API responses holding tokens or personal data stay on your device. Close the tab and nothing remains.
Rates and rules change; check the source before you rely on a figure.
Still stuck? Ask about JSON to C# Class Converter and anybody who knows can answer. No account needed.
Same job, other tools: TSV to JSON – Convert tab-separated values, such as a paste from Excel, into JSON · JSON to YAML – Turn JSON into clean, readable YAML for configs · Query String Parser – Split a URL query string into a table of decoded parameters.