JSON to C# / .NET Converter

Paste JSON and get clean C# classes ready for System.Text.Json — nested classes, List<T> arrays, and nullable types included. Conversion runs entirely in your browser; your data is never sent anywhere.

C# output
// Your generated C# classes will appear here.

How to use the JSON to C# converter

  1. Paste a JSON object or array into the JSON input panel, or click Load sample.
  2. C# classes appear instantly in the C# output panel as you type.
  3. Change the Root class name to match your project's naming convention.
  4. Use Copy to copy the classes, or Download .cs to save them as a file.

What it handles

  • ✓ Nested objects, each promoted to its own class
  • ✓ Arrays mapped to List<T>
  • ✓ Correct int vs double inference
  • ✓ Nullable value and reference types (T?)
  • ✓ [JsonPropertyName] attributes for snake_case or non-PascalCase keys

Example

Input JSON

{
  "id": 1,
  "first_name": "Tayyab",
  "is_active": true,
  "address": {
    "city": "Lahore"
  }
}

Generated C#

using System.Text.Json.Serialization;

public class Address
{
    public string City { get; set; }
}

public class RootObject
{
    public int Id { get; set; }
    [JsonPropertyName("first_name")]
    public string FirstName { get; set; }
    [JsonPropertyName("is_active")]
    public bool IsActive { get; set; }
    public Address Address { get; set; }
}

FAQs

Does this tool send my JSON to a server?

No. Parsing and class generation run entirely in your browser with JavaScript. Your JSON is never uploaded, which makes it safe to use with real API payloads.

What .NET JSON library are the generated classes meant for?

The output targets System.Text.Json, the JSON serializer built into modern .NET. Property names are PascalCase, and a [JsonPropertyName] attribute is added automatically whenever the original JSON key differs from the generated C# property name (for example, "first_name" becomes FirstName with a [JsonPropertyName("first_name")] attribute).

How are numbers typed?

Whole numbers become int, and numbers with a decimal point become double. If the same field appears as both across an array of objects, it is widened to double so no precision is lost.

How are nullable fields handled?

A field that is null, or missing on some array items, is generated with a trailing "?" (for example, string? or int?), matching C#'s nullable reference and value type syntax.

What happens with arrays of objects?

Each array of objects produces its own class, named from the singular form of the property (for example, "projects" produces a Project class), and List<Project> is used for the collection.

Related reading