JSON to C# Class Generator

Generate C# classes or records from JSON with nested types, List<T>, nullable types and [JsonPropertyName].

Runs in your browser Free
Processed locally in your browser.

Types are inferred from the sample. Fields missing in some array items become optional; null values become nullable.

From API response to C# model

Writing C# classes for JSON responses by hand during an API integration is slow and error-prone. Paste a sample response and the generator produces strongly typed models ready for System.Text.Json.

Smart type inference

  • Nested objects become their own classes
  • Arrays become List<T>; items in arrays of objects are merged into one type
  • Fields missing in some items become optional and null values become nullable
  • Choose class or record output

Correct serialisation

JSON keys become PascalCase properties and the original name is kept in a [JsonPropertyName] attribute. Your JSON is processed in the browser.

How to use JSON to C# Class Generator

  1. Paste a sample JSON response.
  2. Set the root class name and class/record preference.
  3. Review the generated C# code.
  4. Copy it into your project.

Why use this tool?

Speeds up API integrations in .NET projects and reduces type errors.

FAQ

How are property names generated?

JSON keys are converted to PascalCase and the original key is kept in [JsonPropertyName], so serialisation keeps matching the API.

Can I use it with Newtonsoft.Json?

The code uses System.Text.Json attributes; replace them with [JsonProperty] for Newtonsoft.

Are date fields generated as DateTime?

No. JSON has no date type, so dates are generated as strings; change the property to DateTime or DateTimeOffset if needed.

Related tools