JSON to C# Classes
Generate C# POCO (Plain Old CLR Object) classes from any JSON structure.
Ready.
About JSON to C# Class Generator
When consuming REST APIs in .NET applications, you typically need C# classes that mirror the JSON response structure. Writing these by hand for large, deeply nested responses is tedious and error-prone. This tool auto-generates strongly-typed C# POCO classes from any JSON input.
Generated Code Uses
The output classes are ready for use with System.Text.Json (JsonSerializer.Deserialize<Root>(jsonString)) or Newtonsoft.Json (JsonConvert.DeserializeObject<Root>(jsonString)). Both libraries can automatically map JSON fields to C# properties by name.
Type Mapping
JSON string → C# string | JSON number (integer) → C# int | JSON number (decimal) → C# double | JSON boolean → C# bool | JSON array → C# List<T> | JSON null → C# nullable (string?, int?)
Newtonsoft.Json Attributes
If your JSON uses snake_case (first_name) but you prefer PascalCase in C# (FirstName), add [JsonProperty("first_name")] from Newtonsoft, or [JsonPropertyName("first_name")] from System.Text.Json to the property. Alternatively, configure a JsonSerializerOptions with PropertyNamingPolicy = JsonNamingPolicy.CamelCase.
Records vs. Classes in Modern C#
C# 9+ records are ideal for immutable DTOs: public record User(int Id, string Name);. They come with built-in value equality, pattern matching support, and ToString(). For mutable models that ORM frameworks (EF Core) need to track changes on, traditional classes with properties remain necessary.