Advertisement

JSON to C# Class

Generate C# classes from JSON with auto implemented properties. Nullable reference types, JsonPropertyName hints, and nested classes included.

JSON input

Paste JSON, optionally name the root type, then generate.

Your C# class code will appear here.
Advertisement

Modern C# from raw JSON

The output uses auto implemented properties, nullable annotations, and PascalCase names per C# convention. Paste a sample API response and get a class hierarchy that deserializes with a single JsonSerializer.Deserialize call.

Nullable aware by design

Fields that proved unreliable in the sample become nullable, so the compiler's null state analysis helps you handle missing data instead of throwing NullReferenceException at runtime.

JSON to C# Class FAQs

Which JSON library does the output target?
The classes work with both System.Text.Json and Newtonsoft.Json. Property names match the JSON keys, so deserialization needs no extra attributes in the common case.
What do the question marks mean?
A ? marks nullable types like string? or int?, used for fields that are null or missing in the sample. This aligns with C# nullable reference type checking.
How are nested objects handled?
Each nested object becomes its own public class named after its key, so the output mirrors the JSON tree as a clean class hierarchy.
How are arrays typed?
JSON arrays become List<T> with T inferred from the elements, which both major JSON libraries populate automatically.
Can I control the property naming?
The generator uses PascalCase properties matching C# conventions. If your JSON keys differ in case, add a JsonPropertyName attribute or a naming policy on the serializer.
Advertisement