Skip to content
ZeroServer.tools

JSON to C# Class

Generate C# classes from a JSON object

using System.Collections.Generic;
using Newtonsoft.Json;

public class Address
{
    [JsonProperty("street")]
    public string Street { get; set; }
    [JsonProperty("city")]
    public string City { get; set; }
    [JsonProperty("zip")]
    public string Zip { get; set; }
}

public class Root
{
    [JsonProperty("id")]
    public int Id { get; set; }
    [JsonProperty("name")]
    public string Name { get; set; }
    [JsonProperty("email")]
    public string Email { get; set; }
    [JsonProperty("active")]
    public bool Active { get; set; }
    [JsonProperty("score")]
    public double Score { get; set; }
    [JsonProperty("tags")]
    public List<string> Tags { get; set; }
    [JsonProperty("address")]
    public Address Address { get; set; }
}

How JSON to C# conversion works

Paste any JSON object and this tool generates a set of C# classes that model its structure. It infers .NET types (int, double, bool, string, List<T>) and recurses into nested objects to produce a full class hierarchy. Property names are converted to PascalCase; when the original JSON key differs, a [JsonProperty] attribute is added so Newtonsoft.Json or System.Text.Json can deserialize correctly. The generated code uses { get; set; } auto-properties — compatible with all major .NET JSON libraries.

Private & free — this tool runs entirely in your browser.

Recommended: IndieKit Ship your Next.js startup in days.affiliate

Related Developer Utilities tools