Tools
Get Pro

JSON to C#

Paste JSON — get C# classes as you type. Nothing leaves your browser.

to
JSON
Loading the converter…
C# options
› More options & type detection

JSON to C# example

Turn an API response or config file into C# model classes you can deserialize into. Each JSON object becomes a public partial class with get/set properties, nested objects get their own class, and fields missing from some items become nullable.

JSON input
{
  "orderId": 1001,
  "customer": {
    "name": "Ada Lovelace",
    "email": "ada@example.com"
  },
  "items": [
    {
      "sku": "BK-001",
      "quantity": 2,
      "unitPrice": 12.5
    },
    {
      "sku": "PN-114",
      "quantity": 1,
      "unitPrice": 3.99,
      "giftWrap": true
    }
  ],
  "couponCode": null,
  "placedAt": "2026-10-20T09:30:00Z"
}
Generated C# — default settings, type name Order
namespace QuickType
{

    public partial class Order
    {
        public long OrderId { get; set; }
        public Customer Customer { get; set; }
        public Item[] Items { get; set; }
        public object CouponCode { get; set; }
        public string PlacedAt { get; set; }
    }

    public partial class Customer
    {
        public string Name { get; set; }
        public string Email { get; set; }
    }

    public partial class Item
    {
        public string Sku { get; set; }
        public long Quantity { get; set; }
        public double UnitPrice { get; set; }
        public bool? GiftWrap { get; set; }
    }
}
Plain classes by default
With “Plain types only” on, you get POCOs without attributes or helper code. Turn it off to add [JsonPropertyName] attributes and a FromJson/ToJson converter for System.Text.Json, or pick Newtonsoft under Serialization framework.
PascalCase property names
orderId becomes OrderId. System.Text.Json matches names case-sensitively unless you use JsonSerializerDefaults.Web (ASP.NET Core does) or set PropertyNameCaseInsensitive — or turn off “Plain types only” so every property carries its JSON name.
Optional and null fields
giftWrap is only in one item, so it becomes bool?. couponCode is null in every sample, so its type is unknown and it becomes object — paste a sample where it has a value to get a real type.
Numbers, lists and dates
Whole numbers become long and decimals double; choose decimal for money under “Type to use for numbers”, and List<T> instead of arrays. Turn on Detect dates to get DateTimeOffset instead of string.

Types that match your real data

Built on the open-source quicktype engine, with quieter defaults and a friendlier editor.

Optional fields detected
Fields that are missing or null in some items become optional automatically.
Merge many samples
Paste JSON Lines or an array — every example contributes to one accurate type.
Paste anything
JavaScript objects, trailing commas, single quotes and comments are repaired for you.
Sensible defaults
No surprise enums or date classes — turn detection on only when you want it.
Every option, every language
All of C#’s generator settings, from naming style to framework annotations.
Private & instant
Runs in a background thread in your browser. Share links keep data in the URL only.

Frequently asked questions

How do I convert JSON to a C# class?+

Paste your JSON on the left and the C# classes appear on the right as you type. Set the root class name under Type name, then copy the code or download it as a .cs file.

Does it work with System.Text.Json and Newtonsoft.Json?+

Yes. Plain classes work with either. Turn off “Plain types only” to generate attributes and helper methods, then choose SystemTextJson or NewtonSoft as the serialization framework.

Can I generate records or a different namespace?+

The generator outputs classes, not records. The namespace (QuickType by default), C# version, List<T> or arrays, and decimal or double are all options.

What if my samples have different fields?+

Paste several samples as JSON Lines (one JSON value per line) or as an array of objects. They are merged into one type, and fields missing from some samples become optional.

Can I paste a JavaScript object from the console?+

Yes. Unquoted keys, single quotes, trailing commas and comments are repaired automatically before the types are generated.

Is my data uploaded?+

No. The conversion runs entirely in your browser, in a background thread. Nothing is sent to a server.

Why don’t I see enums or date types?+

By default, string fields stay strings so the output matches your JSON exactly. Turn on “Detect enums” or “Detect dates” under Options to generate enum and date types.

Code generation uses quicktype (Apache-2.0 license).