JSON to C# Class
JSON to C# Class Generator
Paste a JSON object and get C# class definitions with [JsonPropertyName] attributes from System.Text.Json, typed auto-properties, and nested class generation. Compatible with ASP.NET Core, .NET 6+, and Blazor. Runs entirely in your browser.
Where Is This Useful?
JsonSerializer.Deserialize<T>() or as an action parameter.HttpClient with JsonSerializer to deserialize responses directly into it.How to Use
- Paste a JSON object in the input panel
- Set the root class name (defaults to Root)
- Click Generate C# Class or press Ctrl+Enter
- Copy the output or download as a
.csfile - Add namespaces, validation attributes, or Newtonsoft annotations as needed
Type Mapping
- JSON string →
string - JSON integer →
long - JSON float →
double - JSON boolean →
bool - JSON null →
object? - JSON object → named
public classwith auto-properties - JSON array →
List<T>with inferred element type - All properties include
[JsonPropertyName("key")]attribute
Frequently Asked Questions
What serialization attributes does it use?
It uses [JsonPropertyName] from System.Text.Json, the built-in .NET serializer. If you use Newtonsoft.Json, replace with [JsonProperty] from the Newtonsoft.Json namespace.
Is the output compatible with ASP.NET Core?
Yes. ASP.NET Core uses System.Text.Json by default, so the generated classes work directly as controller action parameters or response types.
How are nested objects handled?
Nested JSON objects become separate C# classes referenced as typed properties. Each gets its own class definition in the output.
How is this different from JSON to TypeScript?
JSON to TypeScript generates interfaces for JavaScript/TypeScript frontends. C# classes are for .NET backend applications, Blazor, MAUI, or any C# codebase.
Is my JSON uploaded anywhere?
No. Everything runs locally in your browser. Your data never leaves your machine.
Related Tools