Convert JSON to C# Class

Instantly generate strong-typed C# POJO classes from your JSON data. Supports JsonProperty attributes and nullable handling.

Input JSON
JSON
Settings
Generates C# Classes
Generated C#
C#

What is a JSON to C# Converter? (Tool Introduction)

In modern software architecture, C# backend services frequently communicate with frontend applications and third-party APIs via JSON payloads. To effectively work with this data in .NET core, developers must deserialize these untyped JSON strings into strongly-typed C# objects (Plain Old CLR Objects, or POJOs/DTOs).

`int`, `DateTime`, `boolean`, `List<T>`) and instantly creating nested class hierarchies.

How to Generate C# Classes

  1. Paste JSON Payload: Insert your raw JSON string or API response into the left-hand editor.
  2. Configure Serialization Options: Toggle checkboxes for [JsonProperty] attributes, Null ignoring, and choose whether to generate Fields or standard Properties depending on your project's coding standards.
  3. Click Convert: The tool instantly compiles the JSON payload into valid C# syntax.
  4. Export Code: Click the Copy button to add the classes to your clipboard, or download them as `.cs` files.

Understanding Advanced C# Configuration

Newtonsoft [JsonProperty]

In C#, properties are typically PascalCase (e.g., `FirstName`), while JSON keys are often camelCase or snake_case (e.g., `first_name`). Enabling this attribute creates an explicit mapping for the deserializer, preventing null data binding issues when consuming APIs.

NullValueHandling.Ignore

When building REST APIs in .NET, you may not want to send back empty values. Enabling this setting injects the `NullValueHandling` directive, instructing the Json.net engine to omit the property from the final payload if it is null, saving bandwidth.

Fields vs. Properties

By default, the tool generates C# Properties `public string Name { get; set; }` which encapsulates data logic. If you check "Use Fields", the generator strips the getters and setters, providing simpler `public string Name;` declarations.

System.Text.Json (Property Name)

For developers utilizing the newer native Microsoft serialization library instead of Newtonsoft, checking `[PropertyName]` will instead generate `[JsonPropertyName("key")]` attributes.

Data Privacy & FAQ

No. This tool is a 100% client-side application. The parser that reads your JSON object and generates the `.cs` classes executes entirely within your browser's local memory stack. No backend requests are made.

`List<SubClass>` property in the parent model.

Because JSON payloads don't inherently carry class names, the topmost overarching object is given the default identifier of `Root`. You can safely rename this class in your IDE (e.g., `UserDto`, `OrderResponse`) after exporting the code.

Yes. If the tool detects a `null` value in your sample JSON for a specific field, it will automatically generate the C# property as a nullable type (e.g., `int?` or `DateTime?`) to prevent `NullReferenceException` errors durante runtime data binding.

common ancestors. If types are radically different, it defaults to a `List<object>` or `dynamic`, which can then be cast at runtime using your preferred logic.

Use **Newtonsoft ([JsonProperty])** if you are working on legacy .NET Framework or older .NET Core projects with complex custom serialization needs. Use **Property Name** ([JsonPropertyName]) if you are on .NET 5, 6, 7, or 8 and want to utilize Microsoft’s high-performance native library.