JSON to C# Class Converter
Paste any JSON — an API response, a config file, a webhook payload — and this free
JSON to C# converter instantly generates clean, strongly-typed
C# model classes from your JSON. Nested objects become nested classes, JSON arrays
become List<T>, and every type is inferred automatically
(int, long, double, bool,
DateTime, Guid). Choose
Newtonsoft.Json [JsonProperty] attributes,
System.Text.Json [JsonPropertyName] attributes, or plain POCOs —
then copy the code or download it as a .cs file.
Convert JSON to C#
This json to csharp converter works live: paste JSON on the left, get a C# class generated from JSON on the right — adjust the options first if needed.
// Your generated C# classes will appear here…
JSON → C# type mapping
How this JSON to C# POCO generator infers types from your data:
| JSON value | C# type |
|---|---|
"text" | string |
42 (fits 32-bit) | int |
5000000000 (needs 64-bit) | long |
9.99 | double |
true / false | bool |
null | nullable (int?, string?, …) or object |
"2026-10-09T20:00:00Z" | DateTime |
"3f2504e0-…-0305e82c3301" | Guid |
{…} object | nested class |
[…] array | List<T> |
Example: API response to C# class
Real output from this C# class generator from JSON (root class Book, Newtonsoft attributes):
JSON input
{
"id": 101,
"title": "Clean Code",
"inStock": true,
"price": 45.99,
"tags": [
"programming",
"bestseller"
]
}
C# output
using System.Collections.Generic;
using Newtonsoft.Json;
public class Book
{
[JsonProperty("id")]
public int Id { get; set; }
[JsonProperty("title")]
public string Title { get; set; }
[JsonProperty("inStock")]
public bool InStock { get; set; }
[JsonProperty("price")]
public double Price { get; set; }
[JsonProperty("tags")]
public List<string> Tags { get; set; }
}
Why this JSON to C# class generator
- Live conversion — generate C# classes from JSON as you type, with precise JSON error messages (line & column).
- Both major serializers — Newtonsoft
[JsonProperty]and System.Text.Json[JsonPropertyName]attribute modes, or clean POCOs. - Smart type inference —
intvslong,DateTimeandGuiddetection, jaggedList<List<T>>arrays. - Array shape merging — object arrays with different keys are merged; missing keys become nullable instead of breaking the build.
- Clean naming — PascalCase properties, C#-keyword-safe identifiers, singularized nested class names, original JSON keys preserved via attributes.
- DTO-ready output — perfect for turning any API response into a C# class for ASP.NET Core, with one-click copy and
.csdownload. - Private by design — 100% client-side JavaScript, zero network requests; safe for proprietary API schemas.
Frequently asked questions
How do I convert JSON to a C# class online?
Paste your JSON into the input box above — an API response, a config file, or any JSON payload. This JSON to C# class converter analyzes it live and generates ready-to-paste C# model classes with properties, types, and nested classes. Then copy the code or download it as a .cs file. No signup, no server upload, completely free.
Which JSON serializers do the generated C# classes support?
Three modes. Newtonsoft.Json mode adds [JsonProperty("originalKey")] attributes so property names map back to the exact JSON keys. System.Text.Json mode adds [JsonPropertyName("originalKey")] attributes instead. Plain POCO mode emits clean classes with no attributes at all. Switch modes with the "Attributes" option and the required using directives are added automatically.
How are JSON data types mapped to C# types?
The converter infers the narrowest correct C# type for every value: JSON integers become int (or long past the 32-bit range), decimals become double, true/false become bool, strings stay string, null becomes a nullable type, ISO-8601 date strings become DateTime, GUID strings become Guid, objects become nested classes, and arrays become List<T>. Integers larger than 64-bit are kept as string with a warning comment so no precision is silently lost.
How are nested objects and JSON arrays handled?
Every nested JSON object becomes its own C# class, named after its property (plural names are singularized, e.g. "addresses" becomes class Address). Arrays become List<T>, including jagged arrays like List<List<int>>. When array elements are objects with different shapes, their properties are merged: keys missing from some elements become nullable, and conflicting types fall back to object. A top-level JSON array generates the element class plus a comment showing how to deserialize a List of it.
Does it detect DateTime and Guid values automatically?
Yes. Strings in ISO-8601 format (for example 2026-10-09T20:00:00Z) are typed as DateTime, and 8-4-4-4-12 hex strings are typed as Guid. Both detectors can be turned off in the options if you prefer plain strings.
Is my JSON uploaded to a server?
No. This JSON to C# converter runs entirely in your browser with plain JavaScript — your JSON never leaves your computer, there is no tracking, no account, and no usage limit. That makes it safe for API responses containing internal or sensitive field names.
What naming conventions does the C# model generator apply?
Property names are converted to PascalCase (postal-code becomes PostalCode) and are safe against C# reserved keywords. Class names are singularized and deduplicated automatically. The original JSON key is always preserved via a [JsonProperty] or [JsonPropertyName] attribute whenever it differs from the generated property name, so deserialization round-trips exactly.
Can I use the generated classes as DTOs or with Entity Framework?
Yes. The output is plain C# POCO classes, ideal as DTOs for ASP.NET Core APIs, for deserializing any API response to a C# class, or as a starting point for Entity Framework models. For EF Core you will typically add your own key and relationship configuration on top, since JSON carries no primary-key metadata.
Free tool by NRTechStudio