JSON to C#

Generate C# classes or records from a JSON sample.

JSON input
C# code

About this tool

Paste a representative JSON document and get C# types that System.Text.Json can deserialize it into. Every nested object becomes its own class (or record), arrays become List<T>, and when the root is an array of objects the item type is generated.

Type mapping

  • Whole numbers → int, long outside the 32-bit range, ulong for positive values beyond long, and decimal beyond 64 bits. A number written with a decimal point or exponent (2.0, 1e3) → double.
  • true/false → bool; text → string; valid ISO-8601 dates such as 2024-05-17 or 2024-05-17T09:30:00Z → DateTime (optional; impossible dates like 2024-02-30 stay string).
  • null-only values, empty arrays and mixed-type arrays → object.
  • A value type that is null in any sample always becomes nullable (int?, DateTime?), since deserializing null into int fails. With Nullable types on, properties missing from some items and reference types are marked nullable too.

Options

Use records emits positional records (attributes use the property: target). PascalCase properties renames first_name to FirstName; keep [JsonPropertyName] on so the original JSON names still map.

Privacy

Code is generated entirely in your browser. The JSON you paste is never uploaded, stored or logged.