Convert JSON to C# Class
Instantly generate strong-typed C# POJO classes from your JSON data. Supports JsonProperty attributes and nullable handling.
Settings
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
- Paste JSON Payload: Insert your raw JSON string or API response into the left-hand editor.
- 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. - Click Convert: The tool instantly compiles the JSON payload into valid C# syntax.
- 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.