Paste a JSON sample and get clean C# classes ready for System.Text.Json — nested objects become their own classes, arrays become List types, and every property carries a [JsonPropertyName] attribute. Fast, secure, and entirely in your browser.
No installation, no signup. Results in milliseconds.
A JSON to C# converter reads a sample of JSON and writes the C# classes that describe its shape, ready to deserialize with System.Text.Json (or Newtonsoft.Json). Instead of hand-writing a class for every API response, you paste the response and get typed classes you can drop into your project.
.NET needs a type to deserialize JSON into, and writing those classes by hand for a large payload is slow and error-prone, especially the attributes that map PascalCase properties to the API's camelCase or snake_case keys. Generating them from a real sample means the properties, types, and attributes match the data exactly.
List<string>, List<Item>).long?) where null appears.[JsonPropertyName] attribute per property, and the usings you need.These are the inference rules the converter applies so the output is predictable.
| JSON | Becomes in C# |
|---|---|
Object { } | A class with one auto-property per key. |
| Nested object | Its own named class, referenced from the parent property. |
Array [ ] | A List<T> such as List<string> or List<Item>. |
| Whole number | long (long? when nullable). |
| Decimal number | double (double? when nullable). |
| string / boolean | string / bool (bool? when nullable). |
| null only / mixed types | object (or List<object> for a mixed array). |
Every property gets a [JsonPropertyName("key")] attribute carrying the original JSON key, so a PascalCase C# property maps to a camelCase or snake_case key without a global naming policy. When a value type is sometimes null in the sample, it becomes nullable (long?, double?, bool?) so a missing value is representable. Validate the JSON first with the JSON parser if it will not convert, or tidy it in the JSON formatter.
objectA field that is only ever null, an empty array, or holds more than one unrelated type has no single concrete C# type, so it falls back to object. Paste a representative sample with those fields populated to get precise types, and give an array of several records so every key is seen. For a deeply nested payload, expanding it in the JSON viewer first helps you confirm the shape.
See how a nested object with an array of items becomes clean, attributed C# classes.
Notice three things: items became its own Item class and a List, Total is a double because the sample has a decimal, and every property carries its [JsonPropertyName] attribute. For the step-by-step reasoning, see our guide on converting JSON to C# classes.
Typed classes from real data, in seconds.
Everything developers ask about generating C# classes from JSON.
[JsonPropertyName("key")] attribute using the original JSON key, so a PascalCase C# property still maps to a camelCase or snake_case key. You can turn the attributes off if you prefer plain properties.long and numbers with a decimal point become double. If a field is sometimes null, the value type becomes nullable, such as long?, so a missing value is representable.public TYPE Name { get; set; }, in PascalCase as C# conventions expect, with the original key preserved in the JsonPropertyName attribute.List<string> or List<Item>, with the element type inferred from the items.object (or List<object> for a mixed array).JsonSerializer.Deserialize<Root>(json). For Newtonsoft.Json, swap the attribute for [JsonProperty] and call JsonConvert.DeserializeObject<Root>(json).Hands-on articles from our blog.
All free, all browser-based, no signup required.