EN
My tools

JSON to C# Class Generator

Turn JSON into C# classes or records with List<T>, nullable types, DateTime and Guid detection, and System.Text.Json or Newtonsoft attributes.

C# code
Types generated
3

object is used where every sample was null or where the samples mix different kinds of values — replace it with the real type once you know it.

Numbers written as 10.0 are read as whole numbers, so a field whose samples are all like that becomes int — include one sample with a fraction to get double.

My tools →
Advertisement

Paste a JSON response and get C# model classes you can deserialize it into. Nested objects become their own classes, arrays become List<T>, and when an array holds several objects their fields are merged, so a field missing from some items or sometimes null becomes nullable (int?, string?). An attribute with the exact JSON name lets camelCase or snake_case keys map to PascalCase properties. The JSON never leaves your browser.

How to use this tool

  1. Paste a representative JSON sample — arrays with several items give the best types.
  2. Set the root class name and, if you want, a namespace.
  3. Choose classes or positional records, and System.Text.Json, Newtonsoft or no attributes.
  4. Decide on nullable reference types and on DateTime/Guid detection.
  5. Copy the code into a .cs file.

Formula

whole number → int (long beyond ±2,147,483,647) · fraction → double · true/false → bool · text → string · ISO date → DateTime · UUID → Guid · [ … ] → List<T> · { … } → class

Values seen at the same place are merged: int and double become double, mixed kinds become object. A member that is null in some sample or absent from some array item is nullable: value types always get ?, reference types get ? when nullable reference types are on. Identical object shapes share one class; list item classes are named from the singular of the key (orders → Order).

Example

The sample user gives three classes. Root has int Id, string Name, string Email, bool IsActive, double Balance, DateTime CreatedAt, List<string> Tags, Address Address, List<Order> Orders and object? Manager (null in the sample). Order has string OrderId (from order_id), double Total (59.9 and 12 merge to double), int Items and string? Coupon, nullable because only the second order has a coupon.

Frequently asked questions

System.Text.Json or Newtonsoft?

New .NET projects use System.Text.Json, which is built in; its attribute is [JsonPropertyName("…")]. Pick Newtonsoft if the project already uses Json.NET; its attribute is [JsonProperty("…")]. With attributes the C# names can follow PascalCase while the JSON keeps its own spelling.

Why does the compiler warn that a non-nullable property is uninitialized?

With nullable reference types on, warning CS8618 appears for string or class properties that are never set in a constructor. Add required (C# 11), give them a default value, or make them nullable if the API can omit them.

When should I use records?

For data you only read: positional records are compact and immutable, and both serializers fill them through the constructor.

Why is a field typed object?

Every sample was null, or the samples mix kinds such as numbers and text. Use a sample with a real value, or edit the type by hand.

Sources

Last updated:

Cite or embed this tool
APA

kakaoCalc. (2026, November 8). JSON to C# Class Generator. https://kakao.mobile/tools/json-to-c-class-tool/

MLA

“JSON to C# Class Generator.” kakaoCalc, 8 Nov. 2026, kakao.mobile/tools/json-to-c-class-tool/.

Paste this code into your page. The widget runs in your visitors' browsers, shows no ads and keeps a link back to this page. Embedding terms

Advertisement