JSON to C# Class
Generate System.Text.Json C# POCOs from a JSON object
About JSON to C# Class
Creates C# classes with PascalCase auto-properties and [JsonPropertyName] attributes from a JSON sample: Root plus one class per nested object. Arrays become List<T> typed from their first element, whole numbers int and decimals double. Each class carries its own using directives, so save the classes as separate .cs files or remove the repeated usings before putting them in one file.
Category: Converters.
Frequently asked questions
What is a POCO?
▾
A Plain Old CLR Object (POCO) is a simple C# class with auto-properties and no framework dependencies — the C# equivalent of a Java POJO.
Which serializer are the attributes for?
▾
The [JsonPropertyName] attributes come from System.Text.Json, the built-in .NET serializer available from .NET Core 3.0+. No extra packages needed.
How are nullable types handled?
▾
A null in the sample becomes object?, since its real type can't be inferred; replace it with the actual type, such as string? or int?. The ? annotations rely on nullable reference types (<Nullable>enable</Nullable> in your .csproj), which will also warn about non-nullable reference properties like string until you initialize them or mark them required.
How do I deserialize with System.Text.Json?
▾
Root root = JsonSerializer.Deserialize<Root>(jsonString)! — the [JsonPropertyName] attributes handle camelCase JSON to PascalCase property mapping.