DT Dev Tools

JSON to C# Class Generator

Convert JSON to C# classes online. Generates models with System.Text.Json or Newtonsoft.Json attributes, nullable types and List<T> — free and private in your browser.

🔒 Runs entirely in your browser — nothing is uploaded

Advertisement

Turn JSON into C# model classes

This JSON to C# converter reads a JSON sample and generates strongly typed C# classes that match its shape. Every object becomes a public partial class, every property gets a PascalCase name with a serializer attribute that maps it back to the original JSON key, and nested objects become their own classes named after the property that holds them. Arrays turn into List<T> or T[], ISO dates become DateTimeOffset, and values that are sometimes missing or null are emitted as nullable types so your code compiles against real-world payloads instead of an idealised one.

Under the hood the tool uses quicktype, a mature type-inference engine that merges every element of an array before deciding on a type. That means a list of orders where only some orders carry a coupon still produces one Order class with an optional Coupon property, rather than a class that only fits the first element.

System.Text.Json or Newtonsoft

Modern .NET projects usually rely on System.Text.Json, which is the default here: properties are decorated with [JsonPropertyName] and the output includes a FromJson factory, a ToJson extension method and converter settings for ISO dates. If your codebase still uses Json.NET, switch the serializer to Newtonsoft and you get [JsonProperty] attributes with the same helpers built on JsonConvert instead. Choose Classes only when you just want the POCOs to paste into an existing DTO folder, and set the namespace so the file drops straight into your solution.

Tips for accurate C# types

Paste the richest sample you can find: include optional fields, empty and populated arrays, and more than one array element so the inference can see which properties are always present. Rename the root class from Root to something meaningful such as OrderResponse before downloading — the file name follows it. After pasting the code into Visual Studio or Rider, review types the sample cannot reveal: an integer ID that may exceed long, a string that is really an enum, or money values that deserve decimal. Everything runs locally, so it is safe to use production responses while you work.

How to use

  1. Paste JSONPaste a JSON object or array, or click Load sample to try it out.
  2. Set optionsChoose the root class name, namespace, serializer and collection type.
  3. Copy the classesCopy the generated C# or download it as a .cs file for your project.

Frequently asked questions

Does it support System.Text.Json and Newtonsoft.Json?
Yes. Pick the serializer and the generator emits matching [JsonPropertyName] or [JsonProperty] attributes plus converter helpers for that library.
Can I get plain classes without the serializer helpers?
Yes. Tick Classes only to output just the model classes, which is handy for DTOs, records you plan to edit, or projects with their own JSON setup.
How are dates, decimals and nulls typed?
ISO 8601 strings become DateTimeOffset, numbers with fractions become double, and fields that are missing or null in some samples become nullable.
Is my JSON uploaded anywhere?
No. The quicktype engine runs entirely in your browser, so API responses and secrets never leave your device.
Advertisement