Convert JSON to C# classes or records with JSON attributes
A free JSON to C# converter: paste JSON and get POCO classes or records back instantly. Choose a plain class with get/set properties for mutable models, or a positional record for immutable value types. Property types are inferred from the data, nested objects become their own classes, and [JsonPropertyName] (System.Text.Json) or [JsonProperty] (Newtonsoft.Json) attributes preserve the original JSON key names. Conversion runs entirely in your browser, so your JSON is never uploaded to a server.
Output formats: Class (POCO with get/set auto-properties), Record (Immutable C# 9+ positional record).
| Option | What it does |
|---|---|
| Root Class Name | Names the top-level POCO. |
| Namespace (optional) | Emitted as a file-scoped namespace (C# 10+) at the top of each file. |
| Field Naming Convention | One of PascalCase, camelCase, Preserve Original. Defaults to PascalCase. |
| Type for null values | Either object or string, used when a key is null in every sample. |
| Non-nullable value types | Emit int / long / double / bool instead of int? / long? / double? / bool? for fields present in every sample. |
| Separate Classes | Write each class to its own .cs file. Off (the default) puts every class in one file, so Copy All pastes into a single file that compiles. |
| Add JSON attributes | Annotate properties with the original JSON key — [JsonPropertyName] or [JsonProperty], depending on the library. Without them a property only binds to a key spelled exactly like it (System.Text.Json is case-sensitive), so snake_case or camelCase keys are silently ignored. |
| Nullable reference types | Emit #nullable enable and mark string, object, List<T> and class properties as nullable (string?). Off emits #nullable disable. |
| JSON library | One of System.Text.Json or Newtonsoft.Json; picks which JSON library the generated code is written for. |
| JSON value | C# type |
|---|---|
| string | string |
| integer | int (int?) |
| integer beyond 32 bits | long (long?) |
| decimal | double (double?) |
| true / false | bool (bool?) |
| ISO-8601 timestamp | DateTime (DateTime?) |
| array | List<T> |
| object | nested class |
| null | object (configurable) |
{
"id": 12345,
"product_name": "Wireless Mouse",
"price": 24.99,
"in_stock": true,
"tags": ["electronics", "accessories"],
"manufacturer": {
"name": "Acme Corp",
"country": "US"
}
}
public class Product
{
[JsonPropertyName("id")]
public int? Id { get; set; }
[JsonPropertyName("product_name")]
public string ProductName { get; set; }
[JsonPropertyName("price")]
public double? Price { get; set; }
[JsonPropertyName("in_stock")]
public bool? InStock { get; set; }
[JsonPropertyName("tags")]
public List<string> Tags { get; set; }
[JsonPropertyName("manufacturer")]
public Manufacturer Manufacturer { get; set; }
}
Paste your JSON into the input pane and the C# classes appear beside it immediately. Pick Class for a mutable POCO with get/set properties or Record for an immutable positional record, set the root class name and an optional namespace, then copy the code or download it. Nested JSON objects become their own classes and arrays become List<T>.
POCO stands for Plain Old CLR Object: an ordinary C# class with properties and no dependency on a framework base class. POCOs are what System.Text.Json and Newtonsoft.Json deserialize JSON into, so turning a JSON sample into a POCO is the usual first step when consuming a JSON API from C#.
System.Text.Json ships with .NET and is the default for new projects; it emits [JsonPropertyName] from System.Text.Json.Serialization. Newtonsoft.Json is a separate NuGet package that many existing codebases still use; it emits [JsonProperty] from Newtonsoft.Json. The generated properties are identical apart from the attribute and its using.
A JSON value can be null or missing, and a plain int would silently turn that into 0. The default keeps the nullable form so nothing is lost; turn on Non-nullable value types to get plain int, long, double, and bool for fields that are present in every sample.
No. Parsing, type inference, and code generation all run in your browser using JavaScript. Your JSON is never sent to a remote server, and there is no account to create. The page keeps your last input and settings in your own browser (localStorage) so they survive a reload; nothing is stored anywhere else.
The conversion itself never transmits your JSON, so a confidential payload does not leave your machine. You can verify this: open your browser DevTools, switch to the Network tab, and convert something — no request carries your data. Two things to know: your last input is saved in your browser's localStorage (clear site data to remove it), and the Copy Link button embeds your JSON in the link, so anyone who opens that link, and the server that receives the request, can see it. Only share such links where you are comfortable with that.
No. The generator is free to use with no sign-up and no usage limits.
Each nested JSON object becomes its own named type, derived from the key it appeared under. Arrays of objects are widened across every element, so a field that is a whole number in one element and a fraction in another gets a type that holds both.