JSON to C#

Convert JSON to C# POCO classes with JsonPropertyName attributes. Supports records (C# 9+), nullable reference types, and PascalCase conversion.

100% private · runs locally

Convert JSON to C# POCO classes instantly. All JSON keys are converted to PascalCase properties, correct .NET types are inferred (int, double, bool, List<T>), and serialization attributes are added for seamless System.Text.Json or Newtonsoft integration.

JSON input
C# output C#

Related tools

Frequently asked questions

What is a C# POCO class?

POCO stands for Plain Old CLR Object — a simple C# class with no dependencies on framework-specific base classes. POCOs are used to represent data structures (like API response payloads) in a serializable, testable way. They typically contain auto-properties ({"{ get; set; }"}) and are decorated with JSON serialization attributes.

What is the difference between a C# class and a record?

Introduced in C# 9, records are reference types with value-based equality and built-in immutability. Use a class when you need mutable data or inheritance. Use a record for immutable data transfer objects (DTOs) — the compiler generates Equals, ToString, and with-expressions automatically.

When should I use [JsonPropertyName] vs [JsonProperty]?

Use [JsonPropertyName] from System.Text.Json.Serialization if you're on .NET 5+ (the built-in serializer). Use [JsonProperty] from Newtonsoft.Json if your project uses the Newtonsoft NuGet package — still common in .NET Framework and older ASP.NET Core projects.

What are nullable reference types and when should I enable them?

Nullable reference types (NRTs, C# 8+) add compile-time null safety. With NRTs enabled, string cannot be null by default — you must explicitly use string? for nullable strings. Modern .NET projects enable NRTs by default in the .csproj file with {"enable"}.

How are JSON arrays handled in C#?

JSON arrays become List<T> properties. If the array contains objects, a new class is generated for the item type (named from the singular of the property key). Primitive arrays become List<string>, List<int>, etc.

How do I deserialize JSON into these C# classes?

With System.Text.Json: var obj = JsonSerializer.Deserialize<Root>(jsonString);. With Newtonsoft: var obj = JsonConvert.DeserializeObject<Root>(jsonString);. Both will map JSON keys to the matching property using the attribute you've configured.