Omnikit
DevFilesMoneyAll tools
Ctrl K
Dev toolsFile toolsMoney calculatorsAll tools
HomeDeveloper toolsJSON to C# Class Converter
EnglishالعربيةবাংলাDeutschEspañolFrançaisPolskiPortuguêsРусский

JSON to C# Class Converter

dev

Turn a JSON sample into C# classes or records for System.Text.Json or Newtonsoft.Json

Runs in your browser. Nothing you type is sent anywhere. Checked against sources on 16 Oct 2026.

Paste a JSON sample and get C# classes or records with PascalCase properties and the JSON key in a JsonPropertyName or JsonProperty attribute. Whole numbers become int, long past 2,147,483,647, any decimal makes a field double, and a value that is null or missing becomes nullable, such as int?.

Next:
  • JSON to TypeScript Generate TypeScript interfaces or types from a JSON sample
  • JSON Formatter & Validator Format, validate, minify and sort JSON with exact error positions

How to convert JSON to a C# class

1

Paste a JSON sample, such as an API response, into the left box.

2

The C# classes appear as you type, one per object, with PascalCase properties and the JSON key in an attribute on each.

3

Choose System.Text.Json or Newtonsoft.Json, and records with init if you prefer immutable models.

4

Press Copy, or Download to save Models.cs, and deserialize into the root class.

About JSON to C# Class Converter

C# reads JSON into typed classes, and each property needs the right type and a way to find its key. This converter writes those classes from a sample, so a long API response becomes a compiling model in one paste.

How types are chosen.

JSON value C# type
"text" string
true / false bool
42 (whole numbers only) int, or long beyond 32 bits
4.5 (any decimal seen) double
null, and also a type int?, string?
only null, or mixed kinds object?
[ ... ] List<...>
{ } empty Dictionary<string, object>
{ ... } a class of its own

Keys and names. Properties are PascalCase, so user_name becomes UserName and avatar_url AvatarUrl. Every property carries its original key in an attribute, because System.Text.Json matches names case-sensitively unless told otherwise; Newtonsoft gets [JsonProperty] instead. A property that would share its class's name, which the compiler rejects as CS0542, gets Value added.

Arrays of objects. All the objects of an array are merged into one class, so a key that appears in only some of them is still there, made nullable so that its absence reads as null rather than 0 or false. Two objects with exactly the same keys and types share one class.

Options. Records with init give immutable models that compare by value. The root class is called Root unless you name it. When the JSON itself is an array or a single value, a comment says which type to deserialize into, such as List.

Every output was checked by reading the C# back and matching 9 samples against it with the serializers' rules. Nothing you paste leaves the browser.

Frequently asked questions

How do I convert JSON to a C# class?

Paste a JSON sample into the converter and the C# classes appear beside it, one per object, with a JsonPropertyName attribute on every property. Copy them into your project and read the JSON with JsonSerializer.Deserialize<Root>(json), or JsonConvert.DeserializeObject<Root>(json) when Newtonsoft is chosen.

Why does every property have a JsonPropertyName attribute?

System.Text.Json matches property names case-sensitively by default, so a property called UserName would never receive the key user_name. The attribute names the exact key, which keeps C# naming in PascalCase and still reads the JSON without any serializer options or naming policy.

When is a property nullable, such as int? or string?

A property is nullable when the sample shows null for it, or when some objects of an array leave its key out. Without the question mark, a missing number would quietly read as 0 and a missing flag as false, so the nullable type keeps absent and zero apart.

Should I use classes or records?

Records with init accessors suit models you only read, because their properties cannot change after deserialization and two records with the same values compare equal. Classes with set suit models you fill in or edit. Both work with System.Text.Json from .NET 5 and with Newtonsoft.Json.

How are numbers typed in C#?

Whole numbers become int, or long when a value is beyond 2,147,483,647, and a field becomes double as soon as any sample value has a decimal part. Values of different kinds, such as a number in one item and text in another, become object?, which keeps the raw JSON value.

Is my JSON uploaded?

No. The conversion runs in your browser with no request to any server, and the JSON is not stored, so API responses holding tokens or personal data stay on your device. Close the tab and nothing remains.

Sources

  • Microsoft Learn, System.Text.Json: customize property namesJsonPropertyName, and case-sensitive matching by default
  • Newtonsoft.Json documentation, JsonPropertyAttribute nameJsonProperty("key") on a property
  • Microsoft Learn, .NET naming guidelinesPascalCase types and properties
  • Microsoft Learn, compiler error CS0542A member cannot have the same name as its enclosing type

Last verified 16 October 2026.

Rates and rules change; check the source before you rely on a figure.

Still stuck? Ask about JSON to C# Class Converter and anybody who knows can answer. No account needed.

Common uses

  • JSON to C# for Newtonsoft.JsonPaste JSON and get C# classes with [JsonProperty] attributes for Json.NET

Same job, other tools: TSV to JSON – Convert tab-separated values, such as a paste from Excel, into JSON · JSON to YAML – Turn JSON into clean, readable YAML for configs · Query String Parser – Split a URL query string into a table of decoded parameters.

Related tools

All developer tools
Base64 Encode & DecodeText and files to Base64 and back, with URL-safe mode and image previewUnix Timestamp ConverterUnix timestamps to dates and dates to timestamps, in any time zoneJSON to TypeScriptGenerate TypeScript interfaces or types from a JSON sampleCSV to JSONConvert CSV to JSON and JSON to CSV, with a table previewYAML to JSONConvert YAML to JSON and JSON to YAML, with anchors resolvedURL Encoder / DecoderPercent-encode or decode text and URLs, and see every part of a linkColor ConverterHEX, RGB, HSL, HWB, OKLCH and CMYK in both directions, with a contrast checkNumber Base ConverterBinary, octal, decimal, hex and any base to 36, exact at any size, with two's complement
Was this tool helpful?
Omnikit

Small jobs, done in your browser. Free, fast and private. Files are never uploaded.

Files

  • Compress Image
  • Image to PDF
  • Merge PDF
  • Compress PDF
  • PDF to Word
  • Word to PDF

Dev

  • JSON Formatter & Validator
  • Base64 Encode & Decode
  • JWT Decoder, Verifier & Encoder
  • Password Generator
  • UUID Generator
  • Unix Timestamp Converter

Money

  • SIP Calculator
  • EMI Calculator
  • GST Calculator
  • FD Calculator
  • PPF Calculator
  • Lumpsum Calculator
EnglishالعربيةবাংলাDeutschEspañolFrançaisPolskiPortuguêsРусский
GuidesQuestionsAboutHow we checkLaw library (beta)PrivacyTermsDisclosureContactMore: Exam practice (UGC NET Paper 1)Runs in your browser. Nothing is uploaded. © 2026 Omnikit (theomnikit.com)