What this tool does

Paste a JSON document. Get a set of C# class (or record) definitions that round-trip through Newtonsoft.Json, System.Text.Json, or no serializer at all. Nested objects become nested classes, arrays become List<T>, and everything is named in PascalCase per .NET conventions. The generated code drops directly into your project, no manual cleanup needed.

The tool walks the JSON tree, picks the most specific C# type it can prove (int vs double vs string), and emits one class per object shape. Arrays of objects are merged sample-by-sample so a property that's null in one element and "text" in another comes out as string? rather than getting lost.

How to use it

1. Paste JSON in the left pane. The tool runs on every keystroke, debounced so it doesn't fight your typing. 2. Set Root to the class name you want for the top-level object (defaults to Root). It's the only name you have to invent, every nested class is named after the property that contains it. 3. Set Namespace to wrap everything in (e.g. MyApp.Models). Leave blank for top-level code. 4. Pick attributes: none, newtonsoft (emits [JsonProperty]), or stj (emits [JsonPropertyName]). Skip this only if your property names already match JSON keys exactly and you don't need a serializer hint. 5. Toggle Records / EF Core / Validators if you want any of the three layered enhancements (covered below). 6. Copy or Download the .cs file.

Type inference

JSON value C# type
`true` / `false` `bool`
Integer number `int`
Decimal number `double`
String `string`
`null` `object?` (or whatever was inferred from sibling values, with `?` appended)
Object A new nested class named after the property
Array `List<T>` where `T` is the merged shape of all elements
Empty array `[]` `List<object>`

Arrays merge their samples before inference, so an array like [{"a":1},{"a":1,"b":"x"}] produces a class with both A (int) and B (string?), the second property is nullable because not every element had it.

Records, EF Core, FluentValidation

Three independent toggles layer on top of the basic class output:

  • Records, emits public record Name(int Id, string Email) instead of class-with-properties. Use these for immutable DTOs in C# 9+; pairs naturally with init-only properties and value-equality semantics. Attributes are inlined as [property: ...] so they still apply.
  • EF Core, adds [Table("snake_case_name")] to the class and [Column("snake_case_property")] to each property. Auto-detects an Id property and tags it [Key]. Non-nullable strings get [Required] plus [MaxLength(255)]. A DbContext stub is appended so you can wire the model into a context immediately.
  • Validators, adds a <Name>Validator : AbstractValidator<Name> per class. String fields get NotEmpty() + MaximumLength(255). Properties matching /email/i get EmailAddress(). Numeric fields get GreaterThanOrEqualTo(0). A DI registration block is appended so you can paste it into Program.cs.

You can stack all three. The using directives are deduplicated and sorted at the top of the output.

Common gotchas

  • Top-level array. JSON like [{...}, {...}] produces a class for the merged element shape and a // Top-level is an array, use List<Root> comment, since C# can't have a top-level array of an unnamed type.
  • int vs long. The tool emits int for any whole number that fits. If your values exceed 2^31 (e.g. timestamps in milliseconds, large IDs), change int to long after pasting.
  • double vs decimal. JSON doesn't distinguish, the tool emits double. For financial values, switch to decimal manually; double rounding will bite you eventually.
  • Reserved keywords. If a JSON key is a C# keyword (class, string, event), you'll get a compile error. Rename the property and add a [JsonPropertyName] attribute mapping back to the original key.

Privacy

Your JSON, the generated C#, and any recent inputs stay in your browser. Nothing is sent to a server, the tool can be used safely with production schemas, internal API contracts, or anything else you'd rather not paste into a third-party site.

Frequently asked

Does this tool send my JSON to a server?

No. JSON parsing, type inference, and C# code generation all run in your browser. Nothing is uploaded or logged. Recent inputs are saved only to localStorage and can be cleared from the Recent card.

When should I use records instead of classes?

Records are best for immutable DTOs (C# 9+) — API responses, message contracts, value objects. They give you positional constructors, value equality, and with-expressions for free. Use classes when you need mutability, parameterless constructors (some frameworks require these), or older C# versions.

Why does the tool emit double instead of decimal for numbers?

JSON doesn't distinguish between floating-point precisions, so the generator emits double for any non-integer number. For financial or precision-critical values, change double to decimal after pasting — double rounding errors will eventually corrupt money calculations.

What happens with int values larger than 2^31?

The tool emits int for all whole numbers and won't auto-detect long-sized values. If your JSON has timestamps in milliseconds, large IDs, or counters that may exceed about 2.1 billion, manually change int to long after generation.

How are nullable types handled?

If a JSON value is null, the type is suffixed with ? (string?, int?). When merging arrays of objects, properties present in some elements but missing in others are also marked nullable. This matches C#'s nullable reference type system.

What does the EF Core toggle add?

[Table("snake_case")] on each class, [Column("snake_case")] on each property, [Key] on properties named Id (case-insensitive), [Required] + [MaxLength(255)] on non-nullable strings, plus a DbContext stub with a DbSet<T> for every generated class. Drop into a project that references Microsoft.EntityFrameworkCore.

Can I customize the validator rules?

Not from the toolbar — the rules are heuristics (NotEmpty + MaxLength on strings, EmailAddress on properties matching /email/i, GreaterThanOrEqualTo(0) on numbers). Generate the boilerplate, then tighten the rules manually for your business logic.

What if a JSON key is a C# reserved word like 'class' or 'event'?

The tool generates the property as-is, which won't compile. Rename the C# property to something safe (Class → ClassName, Event → EventName) and add a [JsonPropertyName("class")] attribute so serialization still maps to the original JSON key.