JSON to C# class
Turn a JSON sample into ready-to-use C# classes.
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.