JSON to C# Class Generator

Paste JSON, get C# code instantly. Private, in your browser.

Input

Output

Ready
Ln 1, Col 1

Convert JSON to C# in one step

Paste JSON and get C# classes with PascalCase properties mapped to the original keys through [JsonPropertyName], for .NET 6 and later.

How to use it

  1. Paste a JSON sample into the Input panel, open a file, or drop it onto the page. A sample is already loaded so you can see the result.
  2. The C# code appears instantly in the Output panel and updates as you type.
  3. Rename the top-level type under Settings → Root type name, and use Sort keys to order fields alphabetically.
  4. Copy the code or Download it as Root.cs.

What the C# generator produces

  • Auto-properties with [JsonPropertyName("key")] attributes.
  • long, double, bool and string, with ? for optional or nullable values.
  • Arrays become List<T>; non-nullable strings, lists and objects are initialised to avoid null warnings.
  • Property names that would clash with the class name are adjusted automatically.

Using the generated C# code

Deserialize with System.Text.Json:

using System.Text.Json;

var data = JsonSerializer.Deserialize<Root>(json);
Console.WriteLine(data?.Users[0].Name);

More JSON tools

All tools are free and run privately in your browser.

JSON to C# FAQ

Can I use Newtonsoft.Json instead?

Yes. Replace [JsonPropertyName] with [JsonProperty] and the using directive with using Newtonsoft.Json.

Is my data uploaded to a server?

No. The JSON to C# runs entirely in your browser using JavaScript. Your data is never uploaded, logged or stored, and the tool keeps working offline after your first visit.