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.
Frequently Asked Questions
Auto-properties or fields?
C# convention favors auto-properties (get; set;) over public fields. Both compile to the same wire format. Pick fields only if you need exact memory layout or are emitting source for a serializer that prefers them.
System.Text.Json vs Newtonsoft.Json?
The generated [JsonPropertyName] attribute is the System.Text.Json (.NET Core 3.0+) attribute. For Newtonsoft.Json (Json.NET), rename it to [JsonProperty] after generation — both libraries do the same thing.
How are integer types decided?
Integers within int32 range (±2,147,483,647) use int. Larger integers use long. Any number with a decimal uses double — switch to decimal manually for monetary values.
Does this support records?
Not directly — the output uses classes with auto-properties. Convert to a record manually for an immutable type with value-based equality.
Does this send my JSON anywhere?
No. All generation happens locally in your browser.
Related Tools
JSON to Java Converter
Generate Java POJO classes from a JSON example. Infers types, creates nested classes, handles arrays as List<T>, and optionally uses Lombok @Data or full getters/setters.
JSON to TypeScript Interface
Convert any JSON object into TypeScript interfaces instantly — handles nested objects, arrays, union types, optional fields, and generics.
JSON to Proto Converter
Generate a Protocol Buffers (proto3) schema from an example JSON object. Infers field types, creates nested messages, and handles arrays as repeated fields.
JSON to Dart Converter
Generate Dart classes from a JSON example. Includes nullable fields, fromJson factory constructors, and toJson methods for use with Flutter and Dart serialization.
JSON to Go Struct Converter
Generate Go structs from a JSON example. Infers types, creates nested structs, handles arrays as slices, and emits json:"..." struct tags ready for encoding/json.
JSON to Python Converter
Generate Python classes from a JSON example. Choose @dataclass, pydantic BaseModel, TypedDict, or attrs style. Targets Python 3.10+ or 3.9 type syntax.

