How to use the JSON to C# Classes
- Paste a representative JSON sample.
- Set the root class name and choose classes or records.
- Copy or download the generated code.
What does this tool do?
The generator infers C# types from your values — int, long, double, bool, DateTime, string — creates a class for every nested object and a List<T> for every array.
Property names are converted to PascalCase, and [JsonPropertyName] attributes keep them mapped to the original JSON keys for System.Text.Json. Keys that are missing or null in some items become nullable. Everything runs in your browser; nothing you paste is uploaded.
Why use it?
- Classes or records.
- Nested objects and arrays handled.
- System.Text.Json attributes.
Use cases
- Model classes for API responses in .NET apps.
- Typed config objects.
- Quick prototypes in Unity, ASP.NET or MAUI.
JSON keys to C# properties
{ "user_id": 1, "created_at": "2026-10-16T09:00:00Z", "tags": ["new"] }
becomes properties UserId (int), CreatedAt (DateTime) and Tags (List<string>), each with [JsonPropertyName] pointing to the original key.
Common mistakes
- Generating from one sample where some fields are sometimes missing — use several items in an array.
- Assuming numbers will always fit in int — IDs may need long.
- Leaving the generic Root class name in your codebase.
Privacy
The calculation happens instantly in your browser. The numbers you enter are not sent to our servers or saved. There's no account to create and nothing to install.
Frequently asked questions
Does it work with Newtonsoft.Json?
Yes — Newtonsoft matches PascalCase properties to camelCase keys by default. Untick the attributes option for cleaner code.
Classes or records?
Records suit immutable data transfer objects; classes suit objects you modify.
Why PascalCase?
It's the C# convention. The attributes keep the mapping to the original JSON keys.
Is my JSON uploaded?
No, everything runs in your browser.
Content last updated . See how M2Toolkit works.