JSON to C# Class, Record & Model Generator
Convert JSON to clean C# classes, records, DTOs, and models directly in your browser — free, instant, and privacy-friendly.
Runs 100% in your browser — your data is never uploaded to a server.
Your JSON is processed locally in your browser. It is never sent to a server.
Tip: paste an untidy API response and format and validate your JSON before converting it to C#.
JSON to C# Converter
This free JSON to C# converter turns JSON data into ready-to-use C# code. Paste a JSON object or an array of objects, choose whether you want classes or records, and the tool generates strongly typed C# models — including nested types and collections — that you can copy or download as a .cs file. It is built for C#, .NET, and ASP.NET Core developers who work with REST APIs and JSON payloads every day.
What Is a JSON to C# Converter?
A JSON to C# converter reads a JSON document and produces C# source code that represents the same structure. Instead of hand-writing properties for every field in an API response, you generate the model in seconds. It can create C# classes, records, models, DTOs, and POCOs.
Common use cases include:
- Mapping REST API responses to C# models
- Integrating with third-party JSON APIs
- Building request and response DTOs for ASP.NET Core
- Creating deserialization targets for JSON
- Prototyping data models quickly
How to Convert JSON to C# Classes
- Paste your JSON into the input editor.
- Enter the root type name (for example, User).
- Choose Class, Record, or Record struct.
- Select a property naming strategy (PascalCase is recommended).
- Pick System.Text.Json or Newtonsoft.Json if you need attributes.
- Enable nullable reference types or required properties if needed.
- Click Generate C# to produce the code.
- Copy the result or download the .cs file.
JSON to C# Class Generator
The class generator creates traditional mutable C# classes with { get; set; } properties. Classes are a good default for models you need to populate or mutate after deserialization.
public class User
{
public int Id { get; set; }
public string Name { get; set; }
public string Email { get; set; }
}JSON to C# Record Generator
Records are useful when you want immutable, value-oriented data models with built-in value equality. The record generator emits { get; init; }properties. Records aren't universally better than classes — the right choice depends on your application architecture and how the data is used.
public record User
{
public int Id { get; init; }
public string Name { get; init; }
}JSON to C# Model and DTO Generator
The terms model, DTO (data transfer object), and POCO (plain old CLR object) overlap and vary between projects. In practice they all describe simple classes or records that carry data. The types generated here are plain C# types with properties, so they work as a starting point for API models, DTOs, or POCOs — rename the root type to something like UserDto to match your conventions.
JSON to C# Example
Here is a simple JSON object converted to a C# class.
{
"id": 1,
"name": "Sailesh",
"email": "[email protected]"
}public class User
{
public int Id { get; set; }
public string Name { get; set; }
public string Email { get; set; }
}Supported C# Types and JSON Structures
The converter infers sensible C# types from the JSON. Numbers are not all assumed to be int — integers outside the Int32 range become long, and numbers with a decimal point become double. Nested objects, arrays, arrays of objects, and null values are all supported.
| JSON value | C# type |
|---|---|
| string | string |
| integer | int (or long if out of Int32 range) |
| number (decimal) | double |
| boolean | bool |
| null | nullable type / object |
| object | a generated class or record |
| array | List<T> |
Property names are converted to idiomatic PascalCase by default, and reserved C# keywords and names with spaces, hyphens, or other special characters are turned into valid identifiers — with a serialization attribute added to preserve the original JSON name when needed.
System.Text.Json vs Newtonsoft.Json
When property names differ from the JSON, the generator can add serialization attributes for either library:
System.Text.Json
Built into modern .NET and a good default for many new applications. Uses the System.Text.Json.Serialization namespace and [JsonPropertyName] attributes.
Newtonsoft.Json
A mature library that remains widely used across existing .NET codebases. Uses the Newtonsoft.Json namespace and [JsonProperty] attributes. Neither library is universally better — choose the one your project already uses.
JSON to C# Conversion for ASP.NET Core
Generated models are plain C# types, so they drop straight into ASP.NET Core and .NET projects:
public class User
{
public int Id { get; set; }
public string Name { get; set; }
}
// Deserialize an API response with HttpClient + System.Text.Json
var user = await http.GetFromJsonAsync<User>("/api/users/1");Use the generated types for API responses, API requests, DTOs, JSON deserialization, and typed HttpClient calls.
Is This JSON to C# Converter Private?
Yes — your JSON stays in your browser. This converter processes your input locally using JavaScript, and your JSON is not sent to our server. That makes it safe to convert sensitive API responses or configuration into C# without the data leaving your device.
Frequently Asked Questions
- What is a JSON to C# converter?
- A JSON to C# converter is a tool that reads JSON and generates C# source code — classes, records, or models — that matches the JSON structure. It saves you from writing data models by hand when consuming an API.
- How do I convert JSON to a C# class?
- Paste your JSON into the input, set a root type name, keep the output type as Class, and the C# class is generated instantly. You can then copy it or download a .cs file.
- Can I convert JSON to a C# record?
- Yes. Choose Record (or Record struct) as the output type and the generator produces immutable records with init-only properties instead of mutable classes.
- Can I generate C# DTOs from JSON?
- Yes. The generated classes or records work well as DTOs or API models. Give the root type a name like UserDto and use the output as a starting point for your data transfer objects.
- Can this tool generate nested C# classes?
- Yes. Nested JSON objects become separate C# classes with names inferred from their property names, and arrays of objects generate a class plus a List<T> property.
- Can I convert JSON arrays to C# lists?
- Yes. JSON arrays are converted to List<T> — for example an array of strings becomes List<string>, and an array of objects becomes List<YourClass>.
- Does this JSON to C# converter support System.Text.Json?
- Yes. Choose System.Text.Json to emit [JsonPropertyName("...")] attributes that map C# properties back to the original JSON names when they differ.
- Does it support Newtonsoft.Json?
- Yes. Choose Newtonsoft.Json to emit [JsonProperty("...")] attributes instead. Attributes are only added when a property name has to change to be a valid C# identifier.
- Is this JSON to C# converter free?
- Yes, it is completely free with no sign-up and no usage limits.
- Is my JSON uploaded to a server?
- No. All conversion runs locally in your browser using JavaScript. Your JSON is never sent to, stored on, or logged by any server.
- Can I use the generated code in ASP.NET Core?
- Yes. The generated classes and records are plain C# and work directly in ASP.NET Core and .NET projects as request/response models, DTOs, or deserialization targets for HttpClient.
- What is the difference between a C# class and a record?
- A class is a mutable reference type with { get; set; } properties. A record is designed for immutable, value-oriented data with { get; init; } properties and built-in value equality. Which to use depends on your application.
Related Developer Tools
JSON Formatter & Validator
Format, beautify, validate, and minify JSON online. Runs entirely in your browser.
Open toolJWT Decoder & Inspector
Decode JWT headers and payloads, inspect claims, and check expiration — entirely in your browser.
Open toolSQL Formatter & Beautifier
Format and beautify SQL queries with customizable indentation, keyword casing, and dialect support.
Open toolBase64 Encoder & Decoder
Encode text and files to Base64 or decode Base64 back — with UTF-8, URL-safe Base64, and Data URIs. Runs entirely in your browser.
Open toolUUID Generator & Validator
Generate random UUID v4 and time-ordered v7 identifiers, generate in bulk, validate UUIDs, and inspect versions — all in your browser.
Open tool