Tools

Home
JSON FormatterSQL FormatterJS ValidatorMinify CSS
Merge PDFCompress PDFImage to PDF
JPG to PNGPNG to WebPCrop Image

JSON to C# Class Generator

Paste JSON and instantly generate C# classes with properties and proper type mapping

Your files never leave your browser
JSON Input0 chars, 0 lines
C# Output0 chars, 0 lines
Ready·

Drop a JSON response in, get back typed C# classes with PascalCase properties, nested object classes, and List<T> arrays — all mapped correctly so you skip the manual property-by-property grind. Handles [JsonProperty] attributes, nullable references, and custom namespaces too. And everything runs in your browser. Nothing gets uploaded.

How It Works

Paste JSON
➔
Analyze Types & Structure
➔
Generate C# Classes

The parser walks through your JSON tree, node by node. Strings become string, whole numbers become int (or long if they're big enough), decimals become double, and booleans map to bool. When it hits a nested object, it spins up a new class definition. Arrays get wrapped in List<T> with the element type inferred from whatever is inside.

Examples

Simple User Profile

A basic API response with strings, numbers, and a boolean.

INPUT
{ "name": "Jane Smith", "age": 28, "is_active": true, "balance": 1250.75 }
OUTPUT
public class Root { public string Name { get; set; } public int Age { get; set; } public bool IsActive { get; set; } public double Balance { get; set; } }

Nested Address Object

When JSON has objects inside objects, each one gets its own C# class.

INPUT
{ "id": 42, "address": { "street": "5th Ave", "zip": "10001" } }
OUTPUT
public class Root { public int Id { get; set; } public Address Address { get; set; } } public class Address { public string Street { get; set; } public string Zip { get; set; } }

Array of Products with Tags

A real-world e-commerce response with arrays, nested objects, and mixed types.

INPUT
{ "products": [ { "sku": "WDG-301", "price": 19.99, "in_stock": true, "tags": ["sale", "new"] } ] }
OUTPUT
public class Root { public List<Product> Products { get; set; } } public class Product { public string Sku { get; set; } public double Price { get; set; } public bool InStock { get; set; } public List<string> Tags { get; set; } }

Who Uses This

💻 .NET Developers

Generating model classes from API responses instead of typing them out manually.

📚 Students

Learning how JSON structures translate to strongly-typed C# objects for coursework.

🔧 QA Engineers

Building test fixtures and deserialization classes for API integration tests.

🚀 Full-Stack Devs

Quickly scaffolding C# backend models that match the JSON their frontend sends.

Common Mistakes

Pasting invalid JSON

Trailing commas, single quotes, or unquoted keys will all break the parser. Run your JSON through a validator first if you copied it from logs or a console. The error message points to the exact line.

Forgetting JsonProperty for snake_case keys

Your API returns first_name but C# expects FirstName. Without the [JsonProperty] attribute enabled, deserialization silently fails and you get null values. Toggle it on before generating.

Using a JSON array as the root

If your JSON starts with [ instead of {, some generators choke. This one handles it fine — it wraps the array in a root class automatically. But know that your deserialization call needs List<Root> rather than just Root.

Technical Details

Frequently Asked Questions

What C# types does the generator map JSON values to?

Strings become string, whole numbers become int (or long if they exceed int range), decimals map to double, and booleans become bool. Null values default to object. Arrays turn into List<T> with the type inferred from the array contents.

How does it handle nested JSON objects?

Each nested object becomes its own C# class. An "address" field with street and city inside it produces a separate Address class. The parent class gets a property typed as Address pointing to it. This nesting goes as deep as your JSON does.

Can I use the output with System.Text.Json instead of Newtonsoft?

The generated classes work with both. If you turn off the JsonProperty toggle, you get plain classes that System.Text.Json handles out of the box (it does case-insensitive matching by default in .NET 6+). For older versions, swap [JsonProperty] for [JsonPropertyName] from System.Text.Json.Serialization.

Is my JSON data sent to a server?

No. Everything happens in JavaScript inside your browser. Your JSON never leaves your machine — not to our servers, not to any third party. You can disconnect from the internet and the tool still works perfectly.

Why are some properties showing as object instead of a specific type?

That happens when a JSON value is null. The generator can't infer a type from null, so it falls back to object. Fix it by providing a sample JSON where those fields have actual values, or manually change the type in the output after generating.

Share: