JSON to C# Converter
Paste JSON, get a C# model for it.
Updated
This tool runs in your browser. No account or signup is required.
Common JSON to C# tasks
Developers typically reach for this page when they need to generate C# classes from JSON; convert API JSON to C# classes; create C# model from JSON. The tool is built for quick, practical work rather than a generic demo.
What matters in a json to c# workflow
When developers compare online tools for this job, the useful capabilities tend to center on nested type inference, root class naming, copy/download. This page keeps those practical needs in mind while linking to related tools when a different workflow is a better fit.
What is JSON to C#?
JSON to C# reads a JSON object and writes a C# type with one field per top-level key. Numbers become double, text becomes string, true/false becomes bool.
What problem does it solve?
Typing out model classes by hand for every API response is repetitive. Generating the first draft from a real JSON sample saves the boring part.
How to use JSON to C#
- Paste a JSON object into the input box.
- Press the convert button.
- Copy the generated C# code and adjust names or types to fit your project.
Example
Input
{"id":1,"name":"Ada"}C# output
public class Root {
public double Id { get; set; }
public string Name { get; set; }
}What you can do with JSON to C#
- JSON to C#
- Generate C# class from JSON
- C# model from JSON
Common use cases
- Creating models for a new API integration
- Mocking a type from a sample response
- Starting a DTO without typing every property
Related developer tasks
- JSON to C#
- Generate C# class from JSON
- C# model from JSON
How the C# output is generated
- The class is named Root and gets one property for each top-level key.
- Numbers become double, true/false becomes bool and text becomes string.
- Nested objects, arrays and null values become object, so refine those by hand.
- Property names have their first letter capitalized: "name" becomes Name.
What to adjust after generating
- Rename Root to something meaningful such as OrderDto.
- Change double to int, long or decimal where the data calls for it. One sample cannot tell them apart.
- Replace object with a real nested class or a List<T>.
- Mark properties nullable if a field can be missing.
Matching property names when you deserialize
System.Text.Json matches property names case-sensitively by default, so a JSON key "name" will not fill a property called Name unless you allow it. Either enable case-insensitive matching or add an attribute such as [JsonPropertyName("name")]. Newtonsoft.Json matches case-insensitively by default.
var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true };
var root = JsonSerializer.Deserialize<Root>(json, options);Related: JSON to TypeScript, JSON Formatter, JSON Validator
JSON to C# FAQ
Does it handle nested objects and arrays?
It maps top-level keys. Nested objects and arrays come out as a generic type (such as object or any), so you will want to refine those by hand.
How are field types chosen?
From the sample values: numbers, booleans and strings get matching types, anything else falls back to a generic type. One sample cannot show whether a field is optional.
Is my data sent to a server?
The processing runs in your browser, so what you paste into the tool is not uploaded for processing. As with any tool, avoid pasting live secrets you cannot afford to leak.
Can it generate nested classes?
No. It maps top-level keys only. Nested objects and arrays are typed as object, and you create the nested classes yourself.
Why are all numbers double?
A JSON sample does not show whether a number is an integer or a decimal, so the tool uses double for every number. Change it to int, long or decimal where appropriate.
Does the output work with System.Text.Json and Newtonsoft.Json?
Yes. The output is a plain class with get/set properties. Check the property-name matching described above before you deserialize.
Related Developer Tools
- JSON Formatter JSON Tools
- JSON Validator JSON Tools
- JSON to TypeScript JSON Tools
- JSON to Java JSON Tools
- JSON to Kotlin JSON Tools
- JSON to Python JSON Tools
- JSON to Go JSON Tools
Looking for something else? Browse all developer tools.

