Data & JSON
JSON to C#
Convert JSON to C# classes with recursive nested types, List<T> collections, type merging across array items, Newtonsoft.Json or System.Text.Json attributes and nullable annotations. Runs locally in your browser.
About this tool
Paste a JSON API sample and get ready-to-use C# classes. Nested objects become separate classes, arrays become List<T>, and fields are merged across every array element, with missing fields marked nullable.
Choose Newtonsoft.Json [JsonProperty] or System.Text.Json [JsonPropertyName] mapping attributes. Properties default to PascalCase or keep original keys; integers map to int/long by range and decimals to double.
Best use cases
- Turn JSON from API docs or network captures into C# deserialization models.
- Draft DTOs, entity classes or configuration models for .NET projects.
- Verify field types and nullability against a JSON sample instead of writing classes by hand.
How to use it
- Paste a JSON object or array; a sample is preloaded.
- Set the root type name and choose serializer attributes, naming and nullable options.
- Select Generate C#, review the code, then copy or download the .cs file.
Scope and limits
- Up to 40 nesting levels and 20,000 nodes; the root must be an object or an array.
- Numbers use JavaScript precision; encode integers beyond the safe range as strings.
- Types are inferred from the sample only. Mixed-type fields fall back to object; review before shipping.
Data processing
Parsing and code generation run entirely in your browser. Nothing is uploaded or stored.
FAQ
How are array objects with different fields handled?
Fields are merged across all array elements: common fields stay, fields missing in some objects become nullable (e.g. int?), and conflicting types widen (int→long→double) or fall back to object.
Newtonsoft.Json or System.Text.Json?
Pick [JsonProperty] for Json.NET projects and [JsonPropertyName] for the built-in serializer in .NET Core 3.0+. Attributes are emitted only when the property name differs from the JSON key.
Is my JSON uploaded?
No. Parsing and generation run locally in your browser, and nothing is retained after you close the page.