JSON to C# Class

FreePrivateInstant
JSON input
C# class
Ctrl+Enter Generate 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?

ASP.NET Core API models
Building a .NET Web API that consumes or returns JSON? Paste the request or response JSON here to get the C# model class you need — ready to use with JsonSerializer.Deserialize<T>() or as an action parameter.
Third-party API integration
Calling an external REST API from your .NET app? Paste a real API response to generate the C# model class, then use HttpClient with JsonSerializer to deserialize responses directly into it.
Blazor and MAUI data binding
Blazor and MAUI apps often consume JSON from APIs. Generate the C# model class from the API JSON response, then bind it to components or views without hand-writing every property.

How to Use

  1. Paste a JSON object in the input panel
  2. Set the root class name (defaults to Root)
  3. Click Generate C# Class or press Ctrl+Enter
  4. Copy the output or download as a .cs file
  5. 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 class with 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