JSON to C# Classes

Paste JSON, get clean C# records or classes ready for System.Text.Json.

Runs locally · nothing uploaded
Detect
JSON
C#

What it does

Paste a JSON document (an API response, a config file, a webhook payload) and get C# types you can paste straight into a .NET project. The output updates as you type.

Why it is better than “Paste JSON as Classes”

  • Looks at every array item, not just the first. A property that is missing from some items, or null in some, becomes nullable (int?, string?), and a number that is 1 in one item and 2.5 in another becomes double.
  • Real type inference: int, or long when a value doesn’t fit; double or decimal for fractions; bool; Guid; DateTimeOffset for timestamps with an offset or Z, DateTime without one, DateOnly for plain dates. Mixed values become JsonElement.
  • Identical shapes are generated once. shippingAddress and billingAddress with the same properties share one Address type.
  • Objects keyed by IDs ({"1": {...}, "2": {...}}) become Dictionary<string, T>.
  • Valid identifiers every time: user_id becomes UserId, names starting with a digit get a _ prefix, C# keywords are escaped with @, and collisions with the class name or other properties are renamed.
  • System.Text.Json attributes only where needed. “Web defaults” assumes ASP.NET Core / JsonSerializerOptions.Web (camelCase); “differs exactly” also covers the default, case-sensitive JsonSerializer.
  • Modern C#: records with init or classes with set, nullable reference types with safe initializers, optional required members, file-scoped namespace.

How to use it

Paste JSON or drop a .json file, set the root type name and namespace, then copy or download the .cs file. The status line shows the JsonSerializer.Deserialize<T> call to use.

Privacy

The conversion runs entirely in your browser. Your JSON is never uploaded; the last input is kept in local storage.