JSON to C# Class Generator
Generate C# classes with JsonProperty attributes from JSON examples.
- 100% client-side · your data never leaves your browser
- Instant, no rate limits
- Free, no sign-up
Your result appears here
Paste JSON into the panel on the left — everything runs privately in your browser.
Overview
JSON to C# Classes — Generate C# Models Online
Generate strongly typed C# classes from a JSON sample. Paste an API response and get ready-to-use POCOs with inferred property types and nested classes for embedded objects — the boilerplate you would otherwise hand-write before deserializing with System.Text.Json or Newtonsoft.Json. Everything runs in your browser, so you can model third-party payloads without pasting them into a remote service.
How type inference works
The generator walks your JSON and maps each value to a C# type: strings to string, whole numbers to int (or long for large values), decimals to double, true/false to bool, and objects to their own nested class. Arrays become List<T>, where T is inferred from the elements. Each nested object produces a named class so the result is a complete, compilable type graph.
Property names follow C# conventions, and a root class wraps the top-level object. The output is designed to drop straight into a .cs file and bind with your JSON serializer of choice.
Why generate models from JSON
- Skip the boilerplate of hand-writing classes for large API responses
- Get compile-time type safety and IntelliSense for untyped JSON
- Model undocumented third-party APIs from a single sample
- Keep DTOs in sync with the actual shape of the data you receive
Working with the generated code
Because types are inferred from one example, review nullability and numeric types before shipping: a field that is null in your sample cannot reveal its real type, and an integer that occasionally exceeds int range should be widened to long. Treat the output as an accurate first draft you refine, not a contract. For other languages, matching generators exist for TypeScript, Go, Python, and Java.
FAQ
Frequently asked questions
Which serializer does the output work with?
The generated POCOs are serializer-agnostic and work with both System.Text.Json and Newtonsoft.Json. Add attributes such as [JsonPropertyName] if your JSON keys differ from C# naming conventions.
How are nested objects handled?
Each nested object becomes its own named C# class, producing a complete type graph rather than dictionaries of objects.
What about nullable fields?
Types are inferred from your sample, so a value that is null in the example cannot be typed precisely. Review and mark optional fields as nullable (for example int?) where appropriate.
Is my JSON sent to a server?
No. Code generation runs entirely in your browser, which makes it safe to model private or proprietary API responses.
Continue with a related tool
All tools- JSON to Java Class Generator
Generate Java classes with Jackson annotations from JSON samples.
- JSON to Kotlin Data Class Generator
Generate Kotlin data classes with @SerializedName from JSON samples.
- JSON to Go Struct Generator
Infer Go struct definitions with JSON field tags from example JSON.
- JSON to Python Converter
Generate Python dict literals or dataclass-style structures from JSON samples.
- JSON to Rust Struct Generator
Generate Rust serde structs with rename attributes from JSON samples.
- JSON to Swift Codable Generator
Generate Swift Codable structs with CodingKeys from JSON samples.