JSON to C# Class — Free Online (.NET)
Convert JSON to C# classes online for free. Auto-properties with [JsonPropertyName] attributes for System.Text.Json. Each shape gets its own class.
PDFFlare's JSON to C# class converter generates one class per unique object shape, [JsonPropertyName]attributes preserving original keys, sensible type inference (long, double, bool, List<T>). Drop the result into a .cs file in any .NET 5+ project and System.Text.Json handles deserialization out of the box.
Need Java instead? JSON to Java POJO. TypeScript? JSON to TypeScript. Go? JSON to Go.
How to Generate C# Classes from JSON
Paste a JSON sample
An API response, config payload, or webhook example representing the shape you want to model in C#.
Click Convert to C#
PDFFlare emits one class per unique object shape with [JsonPropertyName] attributes preserving the original keys.
Drop into your project
Paste the classes into your .cs files, rename Root to your domain type, and System.Text.Json deserializes incoming JSON straight into typed objects.
When Do You Need JSON to C#?
Typing an upstream API: The vendor docs are out of date. Hit the endpoint, copy the JSON response, paste here, get accurate C# classes ready for HttpClient.GetFromJsonAsync.
ASP.NET Core request DTOs: Generate the input model from a real client payload, drop it into the controller as [FromBody] UserRequest, and model binding handles the rest.
Webhook handlers: Stripe, GitHub, and similar services document webhook payloads as JSON examples. Convert each example to a strongly-typed C# class instead of relying on JsonElement indexers.
Migrating from JS/TS to .NET: Porting a Node or Python service to .NET? Seed the type definitions from real production payloads instead of trying to translate hand-written types.
Why Choose PDFFlare's JSON to C# Class Generator?
System.Text.Json Ready
[JsonPropertyName] attributes preserve the original JSON keys — your classes decode incoming payloads correctly with no custom converters.
Auto-Properties
Every field uses standard { get; set; } properties — refactor to records or init-only setters with one pass.
100% Browser-Based
JSON samples stay on your device — safe for internal API contracts and production payloads.
No Signup Required
No account, no rate limits, no watermarks.
Frequently Asked Questions About JSON to C#
Yes. Every property carries a [JsonPropertyName("originalKey")] attribute so System.Text.Json (built into .NET 5+) maps incoming JSON keys onto your PascalCase C# properties without custom converters.
PDFFlare's JSON To C# tool runs entirely in your browser. Swap [JsonPropertyName] for [JsonProperty] (and the using directive from System.Text.Json.Serialization to Newtonsoft.Json). The class structure, types, and properties work identically — only the attribute namespace differs.
Each unique object shape becomes its own public class. Names are inferred from property names (singularized for arrays of objects), giving you defaults like User, Order, Comment. Rename to fit your domain via find-and-replace.
Mixed-type arrays produce List<object> since C# doesn't have native union types. If you know the shape, refine to a more specific generic — or use System.Text.Json's polymorphic deserialization with a custom converter.
Yes. Whole-number values become long; decimal values become double. JSON treats both as 'number' but the converter inspects each value. For currency or precise decimals, swap double for decimal manually.
Reference types fall back to plain object for null fields (object?). For full nullable-aware classes (string?, int?), enable nullable reference types at the project level (#nullable enable) and refine the generated types where you know the field is optional.
No. The conversion runs entirely in your browser — safe for internal API contracts, production payloads, and tokenized responses. Nothing uploads anywhere.
It produces standard auto-property classes matching .NET conventions (PascalCase properties, attributes above each property). Manual passes can refine: convert classes to records, add init-only setters, or apply [JsonRequired] on must-have fields.