AIWalay Tools

JSON to C# Class Converter

Generate C# classes from sample JSON — PascalCase properties, nested classes, List<T> for arrays and nullable types. Copy or download.

About the JSON to C# Class Converter

This tool turns a JSON sample into ready-to-use C# classes. It generates PascalCase properties, creates nested classes for embedded objects, uses List<T> for arrays, picks sensible types (int, long, double, bool, string, DateTime) from the values, and wraps everything in a namespace you choose.

It saves the tedious work of hand-writing model classes to deserialize an API response with System.Text.Json or Newtonsoft.Json. Shapes are merged across array items so the classes cover every field seen in the sample.

Generation happens entirely in your browser, so your JSON never leaves your machine.

How to Use the JSON to C# Class Converter

  1. 1Paste a representative JSON sample.
  2. 2Set the root class name and namespace.
  3. 3Click Generate to produce the C# classes.
  4. 4Copy the code or download it as a .cs file.

Frequently Asked Questions

Which JSON serializer do the classes work with?

Both System.Text.Json and Newtonsoft.Json (Json.NET). Property names are PascalCase per C# convention; if your JSON uses camelCase or snake_case keys, enable case-insensitive matching in System.Text.Json or add [JsonProperty] attributes for exact mapping.

How are types chosen?

Whole numbers become int (or long if large), decimals become double, true/false becomes bool, strings become string, and objects become nested classes. Arrays become List<T> based on their element type. Null values are typed as nullable where inferable.

How are nested objects handled?

Each nested object becomes its own class, named from the property it appears under, and referenced as a property type on the parent. Arrays of objects generate a class for the element type and a List<T> property, so the whole structure is strongly typed.

What if array items have different fields?

The generator merges all objects in an array into one class containing the union of their properties, so no field is lost. Review the result — you may want to make properties that only appear sometimes nullable.

Is my JSON uploaded?

No. The conversion runs entirely in your browser, so the sample JSON is never sent to a server. It's safe to paste real API responses while generating models.

Related Tools