Skip to content
100% local

JSON to C# class

Turn a JSON sample into ready-to-use C# classes.

Input
Output

JSON to C# class

Paste a JSON object or an array of JSON objects and this tool infers the shape and generates matching C# classes. It is built for the everyday task of turning an API response, a config file or a sample payload into strongly typed models without writing them by hand.

The options control how the generated code looks. Pick attributes for System.Text.Json ([JsonPropertyName]), Newtonsoft.Json ([JsonProperty]) or none at all — attributes are added automatically whenever PascalCase renaming changes a property name, so the original JSON key is never lost. Choose properties or fields, switch nullable reference types on or off, generate a record instead of a class, and pick List<T> or T[] for arrays. Nested objects become their own classes named after the property that holds them, and a namespace declaration wraps everything when you supply one.

The tool merges the shapes of every element when you paste an array, so a key that is only present on some items becomes an optional, nullable property instead of silently disappearing. Numbers stay whole numbers (int, widening to long for larger values) unless a decimal point forces double, and a value that is only ever null becomes a nullable object. Class and property names are sanitized and de-duplicated automatically, so invalid or repeated JSON keys never produce broken C#.

Everything runs locally in your browser — your JSON is never uploaded or sent to a server, which matters when the sample comes from a private API or contains real customer data. Copy the generated classes, download them as a .txt file, or send the output back into the input to refine it further.

FAQ

How does it decide between int, long and double?
Whole numbers become int, or long when they exceed the 32-bit range. Any number with a decimal point or that disagrees with a whole number elsewhere in an array becomes double.
What happens to a property that is missing from some array items?
It is generated as a nullable property. With nullable reference types on that adds a "?"; the same applies to a value that is always null.
Can it keep the original JSON key when it renames a property?
Yes. Whenever PascalCase renaming or sanitizing changes a property name, the original key is preserved in a [JsonPropertyName] or [JsonProperty] attribute, depending on the attribute style you choose.
Does it generate nested classes for nested objects?
Yes. Each nested object gets its own class named after the property that contains it, and arrays of objects generate a class named after the singular form of that property.
Is my JSON uploaded anywhere?
No. The conversion runs entirely in your browser — your JSON never leaves your device.