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 anIdproperty and tags it[Key]. Non-nullable strings get[Required]plus[MaxLength(255)]. ADbContextstub is appended so you can wire the model into a context immediately. - Validators, adds a
<Name>Validator : AbstractValidator<Name>per class. String fields getNotEmpty()+MaximumLength(255). Properties matching/email/igetEmailAddress(). Numeric fields getGreaterThanOrEqualTo(0). A DI registration block is appended so you can paste it intoProgram.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. intvslong. The tool emitsintfor any whole number that fits. If your values exceed 2^31 (e.g. timestamps in milliseconds, large IDs), changeinttolongafter pasting.doublevsdecimal. JSON doesn't distinguish, the tool emitsdouble. For financial values, switch todecimalmanually;doublerounding 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.