JSON Parser

JSON to C# Class Converter Online

Paste any JSON and get ready-to-use C# types in one click. Nested objects, arrays, optional fields and awkward key names are handled for you, and everything runs in your browser, so API responses and sample payloads are never uploaded.

How to convert JSON to C#

  1. Paste your JSON, or click Upload to load a file. Use a sample that includes every field, since the types are inferred from it.
  2. Set the Root class name if you want something other than Root.
  3. Review the output on the right and click Copy.

Example

JSON input

{
  "id": 1,
  "name": "Alice",
  "active": true,
  "score": 98.5,
  "tags": ["admin"],
  "address": { "city": "New York" }
}

C# output

using System.Collections.Generic;
using System.Text.Json.Serialization;

public class Root
{
    [JsonPropertyName("id")]
    public long Id { get; set; }
    [JsonPropertyName("name")]
    public string Name { get; set; }
    [JsonPropertyName("active")]
    public bool Active { get; set; }
    [JsonPropertyName("score")]
    public double Score { get; set; }
    [JsonPropertyName("tags")]
    public List<string> Tags { get; set; }
    [JsonPropertyName("address")]
    public Address Address { get; set; }
}

public class Address
{
    [JsonPropertyName("city")]
    public string City { get; set; }
}

JSON to C# type mapping

JSONC#
stringstring
whole numberlong
decimal numberdouble
booleanbool
arrayList<T>
objecta class
null / unknownobject

Naming and structure

Properties are PascalCase with { get; set; }, and each has a [JsonPropertyName("key")] attribute (System.Text.Json) so the original key is preserved.

  • Fields that are null or missing in some items become nullable types such as long? and string?.
  • Using Newtonsoft.Json? Replace [JsonPropertyName] with [JsonProperty].
  • When an array contains objects, their fields are merged: a field missing from some items is treated as optional, and a field that is a whole number in one item and a decimal in another becomes a decimal.
  • The top-level JSON can be an object or an array of objects.

Using the generated types

var root = JsonSerializer.Deserialize<Root>(json);

Related tools

Describe the same data with the JSON Schema generator, get TypeScript interfaces, create a SQL table, fix broken input with JSON Repair, or compare payloads with JSON Diff.

Frequently asked questions

How do I convert JSON to C# classes?
Paste your JSON and copy the classes. Each object becomes a public class with { get; set; } properties in PascalCase, arrays become List<T>, whole numbers become long and decimals become double.
Does it work with System.Text.Json?
Yes. Each property has a [JsonPropertyName("key")] attribute so the original JSON key is preserved when deserializing with JsonSerializer.Deserialize<Root>(json). If you use Newtonsoft.Json, swap the attribute for [JsonProperty].
How are nullable values handled?
Fields that are null or missing in some array items are generated as nullable types (long?, string?, object?). Everything runs in your browser — your JSON is never uploaded to a server.
Handles JSON files up to 20MB smoothly