Skip to content

JSON to C# — Generate Classes from JSON Online

Paste JSON and instantly get C# class definitions with typed properties, nested classes, and List<T> arrays.

Last updated:

Why generate C# classes from JSON

.NET developers frequently consume JSON APIs and need strongly-typed models. Writing classes by hand is tedious and error-prone — especially for large payloads with nested objects and arrays. This tool does it instantly:

  • API integration — paste a sample response from a REST API and get the classes you need for System.Text.Json or Newtonsoft.Json deserialization.
  • Prototyping — quickly scaffold data models for a new project without writing boilerplate.
  • Migration — converting a JavaScript/TypeScript project to C# and need equivalent types.
  • Documentation — generate class definitions from example payloads for API docs or Swagger schemas.

C# classes vs records

This tool can generate either class or record declarations:

  • Classes — mutable reference types with get/set properties. The traditional choice for DTOs and entity models. Works with all .NET versions.
  • Records — immutable value-semantic types introduced in C# 9. Great for DTOs you don't need to modify after deserialization. Built-in equality, ToString, and with-expression support.

If you're on .NET 5+ and your models are read-only data carriers, records are the modern choice. For Entity Framework models or mutable state, use classes.

Type mapping: JSON to C#

  • stringstring
  • integerint
  • decimaldouble
  • booleanbool
  • nullobject?
  • arrayList<T>
  • object → a named class (PascalCase from the key name)

Property names are automatically converted from JSON conventions (camelCase, snake_case) to C# PascalCase. If you need [JsonPropertyName] attributes for custom mapping, add them manually after generation.

Related code generation tools

Frequently Asked Questions

What C# types does it generate?
string for JSON strings, int for whole numbers, double for decimals, bool for booleans, object? for null, and List for arrays. Nested JSON objects become separate named classes.
Does it support C# records?
Yes. Toggle the declaration style from class to record to generate C# 9+ record types instead of classes.
What are nullable reference types?
C# 8+ introduced nullable reference types (string? instead of string). Enable this option if your project uses #nullable enable to get proper annotations.
How are property names generated?
JSON keys are converted to PascalCase following C# conventions. For example, first_name becomes FirstName and userId becomes UserId.
Does it handle nested objects?
Yes. Each unique nested object shape gets its own class. If two properties share the same shape, they share one class definition.
Is my data safe?
Yes. This tool runs entirely in your browser. Your JSON is never sent to any server.

Related Tools