JSON to C# Converter
Paste a JSON object and get ready-to-use C# classes — with field types, nested classes, and optional `[JsonPropertyName]` attributes for `System.Text.Json`.
Last updated: May 27, 2026
Find this tool useful? Support the project to keep it free!
Buy me a coffeeWhat is JSON to C# Converter?
When consuming a JSON API from .NET, you typically declare C# classes that mirror the JSON shape, then use `JsonSerializer` (`System.Text.Json`) or `JsonConvert` (Newtonsoft) to deserialize. Writing those classes by hand is tedious — each field needs a type and a property declaration, and JSON keys that don't match C# naming conventions need a `[JsonPropertyName("...")]` attribute to map correctly.
This tool reads a JSON example and emits the matching class hierarchy. Integers within `int` range use `int`, larger integers use `long`, decimals use `double`, strings use `string`, booleans use `bool`, and nested objects produce nested classes. Arrays become `List<T>` where T is the inferred element type. PascalCase field names follow C# conventions, with a JSON-name attribute added when the JSON key differs.
How to Use JSON to C# Converter
Paste a JSON object (root must be an object).
Set the root class name and an optional namespace.
Toggle auto-properties, PascalCase, [JsonPropertyName], and nullable types.
Copy the generated classes into your project.
Common Use Cases
- Bootstrapping C# DTOs from a sample API response.
- Generating model classes for System.Text.Json or Newtonsoft.Json deserialization.
- Producing record-like model classes for ASP.NET Core controllers.
- Translating an OpenAPI example into C# classes.
Example Input and Output
A flat JSON object generates a C# class with auto-properties.
{ "userId": 42, "name": "Alice", "active": true }public class Root
{
[JsonPropertyName("userId")]
public int UserId { get; set; }
public string Name { get; set; }
public bool Active { get; set; }
}Privacy
All conversion happens in your browser. No JSON is sent to a server.
Reserved keywords
If a JSON key matches a C# keyword (class, namespace, etc.), the field is prefixed with @ to escape it.
Nullable reference types
Enable "Nullable types (T?)" when your project has #nullable enable. The generator adds ? to every reference type so the compiler knows JSON can be missing.

