JSON → C# Class

JSON input
Loading editor...
C# outputLive
Loading editor...
// Generated C# code will appear here...

What is JSON → C# Class?

Generate C# classes from JSON data. Choose between System.Text.Json or Newtonsoft.Json attributes.

Nested objects become their own classes with JSON property attributes and PascalCase members. Output updates as you type, and everything runs in your browser.

Features

  • Generate C# classes and records from JSON
  • System.Text.Json and Newtonsoft.Json support
  • Nullable type handling
  • Nested class generation
  • Proper naming conventions (PascalCase)
  • Copy generated code to clipboard

How to use JSON → C# Class

  1. Paste your JSON. Enter a sample JSON object.
  2. Select serializer. Choose System.Text.Json or Newtonsoft.Json.
  3. Copy C# code. Get production-ready C# classes.

Examples

Generating C# classes

A small user record with a nested address, generated with the default settings. Trimmed to the generated classes. The default output also includes FromJson/ToJson helpers and a converter settings class.

Input

{
  "id": 1,
  "name": "Ada Lovelace",
  "email": "ada@example.com",
  "active": true,
  "tags": ["admin", "dev"],
  "address": { "city": "London", "zip": "EC1A" }
}

Output

    public partial class Root
    {
        [JsonPropertyName("id")]
        public long Id { get; set; }

        [JsonPropertyName("name")]
        public string Name { get; set; }

        [JsonPropertyName("email")]
        public string Email { get; set; }

        [JsonPropertyName("active")]
        public bool Active { get; set; }

        [JsonPropertyName("tags")]
        public List<string> Tags { get; set; }

        [JsonPropertyName("address")]
        public Address Address { get; set; }
    }

    public partial class Address
    {
        [JsonPropertyName("city")]
        public string City { get; set; }

        [JsonPropertyName("zip")]
        public string Zip { get; set; }
    }

Frequently asked questions

What C# features are supported?

Classes, records, nullable types, nested classes, and attributes for System.Text.Json and Newtonsoft.Json.

Can I use this with ASP.NET?

Yes. Generated classes work with ASP.NET Core Web API, HttpClient, and Entity Framework.