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
Input JSON
C# classes

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.

No uploadsNo sign-upOpen source
  1. 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.

  2. 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
  3. 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

Learn more in our guides

All guides