PB
Available
code
lock Free · Private · In-Browser

JSON to C Sharp Class

Turn a JSON sample into System.Text.Json-ready C Sharp classes.

 

Generate C Sharp DTO classes from JSON

System.Text.Json can deserialize directly into classes when property names and value types match the payload. This generator reads a JSON object and produces a public root class plus nested classes for child records. Integers use long, decimal numbers use double, booleans use bool, strings use string, and arrays use generic List fields based on the first example item.

The default object generates User with UserId, Name, and Active properties. Each property receives JsonPropertyName, so user_id continues to match the payload even though the .NET property follows Pascal case. Nested objects are promoted into named classes, providing a quick DTO draft for HttpClient responses, tests, or message contracts.

Reviewing inferred .NET types

One payload cannot identify every nullable or polymorphic field. Explicit null becomes object nullable, empty arrays use a broad object element, and numeric range choices may need int, decimal, or BigInteger instead of the inferred defaults. Conversion stays in your browser and does not transmit the JSON. Apply your project nullable-reference settings and validation rules after checking the actual API specification.

Frequently Asked Questions

Does this use Newtonsoft.Json or System.Text.Json?

It targets System.Text.Json and emits JsonPropertyName attributes.

Why are whole numbers generated as long?

Long is a conservative default for JSON integers whose range is not documented by a single sample.

Will nested records become separate classes?

Yes. Nested objects and arrays of objects produce additional classes referenced by the parent.

Take it further
All Free Tools

Browse the full set of free, private, in-browser tools.

Learn More arrow_forward