JSON to C#
Paste JSON and instantly get strongly typed C# class definitions with inferred types and System.Text.Json attributes.
Example
Input JSON:
{"id":101,"name":"Ada","address":{"city":"London"},"tags":["a","b"]}Generated C#:
public class Root
{
[JsonPropertyName("id")]
public long Id { get; set; }
[JsonPropertyName("name")]
public string Name { get; set; }
[JsonPropertyName("address")]
public Address Address { get; set; }
[JsonPropertyName("tags")]
public List<string> Tags { get; set; }
}
public class Address
{
[JsonPropertyName("city")]
public string City { get; set; }
}How it works
It parses your JSON, infers a C# type for each value (string, long, double, bool, nested classes, List<T>), and emits one class per object with PascalCase properties. Array elements are merged so all keys appear, and the root object becomes a class named Root.
Good to know
JSON to C# turns a sample JSON payload into ready-to-paste C# class definitions. It reads your input, picks a sensible C# type for every value, and writes one class per JSON object, naming the top-level object Root and generating nested classes for embedded objects. It's aimed at .NET developers who need a typed model to deserialize an API response or config file with System.Text.Json, without hand-writing every property.
Reach for it whenever you have an example response but no SDK or schema: scaffolding a DTO for a third-party API, modeling a webhook body, or quickly typing a settings file. It saves the tedious work of mapping each key to a property, choosing types, and remembering the right attribute syntax. Because everything runs in your browser, you can safely paste payloads that contain real data.
To read the output, scan the generated classes top to bottom. Each property shows its inferred type and getter/setter; integers become long, decimals become double, true/false becomes bool, and arrays become List<T>. Where a JSON key doesn't match its PascalCase property name, you'll see a [JsonPropertyName] attribute that preserves the original key during (de)serialization. A status line reports how many classes were produced.
One practical caveat: the tool only knows what your sample contains. A null value is typed as object because its real type can't be inferred, and a key missing from your sample won't appear at all. So feed it a representative example that includes optional fields, and review nullable or numeric types afterward (e.g. an ID that could exceed long, or a value you'd prefer as a nullable type).
Frequently asked questions
What does the JsonPropertyName attribute do?
When a JSON key (like "zip_code") differs from its PascalCase C# property name (ZipCode), the tool adds a [JsonPropertyName] attribute so System.Text.Json maps them correctly during serialization and deserialization.
How are arrays of objects handled?
The tool merges the keys from every object in the array into a single class, so optional fields that appear in only some elements are still included. The property is typed as Listusing that merged class.
Is my data uploaded anywhere?
No — it runs entirely in your browser. Your input never leaves your device and it works offline once loaded.
Is it free?
Yes, completely free with no sign-up and no limits.
People also ask
How do I convert JSON to a C# class?
Paste a representative JSON sample into the input box and click Convert. The tool parses the JSON, infers a C# type for each value, and emits one class per object with PascalCase properties that you can copy straight into your project.
What C# type does the tool use for numbers in JSON?
Whole numbers are typed as long and numbers with a decimal point are typed as double. Because JSON has only one number type, you may want to change these manually to int, decimal, or another type to match your domain.
Why is a property typed as object instead of a real type?
That happens when the value in your sample is null or an empty array, so the tool cannot infer a concrete type. Provide a sample where the field has a real value, then adjust the generated type as needed.
Does the generated code work with System.Text.Json or Newtonsoft.Json?
It targets System.Text.Json, using [JsonPropertyName] attributes and a using for System.Text.Json.Serialization. The classes are plain enough to work with Newtonsoft.Json too, though that library uses [JsonProperty] for custom key names.
How are nested JSON objects and arrays of objects converted?
Each nested object becomes its own class referenced as a property, and an array of objects becomes a List of a generated class whose keys are merged across all elements. Arrays of primitives become List of that primitive type, such as List<string>.
Can I generate nullable properties or records instead of classes?
No, the tool outputs standard classes with non-nullable auto-properties. If you need nullable reference types, init-only setters, or C# records, edit the generated code by hand after copying it.
Is it safe to paste sensitive JSON into this converter?
Yes, the tool runs entirely client-side in your browser, so your input is never uploaded to a server. It also continues to work offline once the page has loaded.
Related tools