Practical Guide

JSON to C# Class Generator โ€” Usage Guide and Technical Principles

Generate C# classes from JSON with nested types and optional JsonPropertyName attributes. Edit with syntax highlighting and download a .cs file.

Open tool

Overview

The generator infers a C# model from sample values. Objects become classes and arrays are represented as lists. A sample helps start a model for an API response or configuration file.

Key concepts

Types inferred from values

Objects become classes, integers become long and decimals become double. Same-type arrays become List<T>, while mixed arrays fall back to List<object>.

Features

Distinct C# property names

Keys that normalize to the same C# name get distinct identifiers. With JsonPropertyName enabled, each attribute preserves its exact JSON key.

Use Cases

Model an API response

Paste a representative JSON response, inspect its nested classes and export the C# source to use in a .NET project.

Frequently Asked Questions

What happens to a top-level array?

A top-level array is wrapped in an Items property, and a primitive is wrapped in Value. For a bare JSON array, deserialize the list type directly.

How is nullability inferred?

The nullable option adds a question mark when the sample contains null. Fields absent from the sample and the full API schema need to be checked separately.

Related Documents

JSON to C# Class Generator

Open the tool to try these features.

Open tool