JSON to C# Converter

Turns a JSON object or array into strongly-typed C# model classes with { get; set; } properties and correctly inferred types including nullable variants, List<T> for arrays, and nested class definitions. Options cover namespace generation, data annotations, nullable reference types, and configurable indentation so the output drops straight into your .NET project. Everything is generated in-browser and can be downloaded as a .cs file.

Input

JSON

Code Style

Naming

1 rows, 7 columns
Output

C# Code

What is JSON to C# Converter?

Generate C# classes with properties and Newtonsoft.Json or System.Text.Json attributes from JSON objects in your browser — no upload, no account required. This browser-based tool maps JSON types to C# equivalents (string, int, double, bool, List<T>, nullable types), produces JsonProperty or JsonPropertyName attributes, and optionally adds record syntax for C# 9+. .NET developers use it to scaffold model classes for ASP.NET Core API controllers, System.Text.Json deserialization targets, and data contracts. All code generation is local — your JSON payloads and schemas never leave your browser.

How to Use

  1. 1

    Paste Your JSON

    Paste a JSON object or array into the editor. Include a representative sample with all expected fields populated — null values produce nullable types in the output.

  2. 2

    Configure C# Class Options

    Set the root class name, choose between plain POCO, System.Text.Json-annotated, or Newtonsoft.Json-annotated output, and optionally enable record types (C# 9+) for immutable models.

  3. 3

    Generate C# Classes

    Click "Generate C#". JSON types are mapped to C# types (int, double, bool, string, List<T>), PascalCase properties are generated with [JsonPropertyName] attributes for non-matching JSON keys, and nested objects generate separate classes.

  4. 4

    Add to Your C# Project

    Copy the generated classes into your project. For System.Text.Json, use JsonSerializer.Deserialize<Root>(jsonString); for Newtonsoft.Json, use JsonConvert.DeserializeObject<Root>(jsonString).

Common Use Cases

ASP.NET Core API Models

Generate C# model classes from JSON request or response payloads to use in ASP.NET Core controllers as strongly-typed [FromBody] parameters and action return types.

Azure Function & Logic App Integration

When consuming JSON payloads from Azure Event Hub, Service Bus, or HTTP triggers, generate C# classes to deserialise the payload with System.Text.Json or Newtonsoft.Json.

Entity Framework Core Scaffolding

Generate C# POCO classes from JSON data samples as a starting point for EF Core entity definitions, then add [Key], [Required], and navigation property annotations.

Unity Game Development

Convert JSON game configuration files or server response payloads into C# classes for Unity projects, enabling JsonUtility.FromJson<T>() deserialisation with proper type safety.

Conversion Examples

JSON Object → C# Class

A JSON object generates a C# POCO with public auto-properties.

Input JSON

{
  "id": 1,
  "firstName": "Alice",
  "email": "alice@example.com",
  "isPremium": true,
  "balance": 250.75
}

Output CSV

public class Root
{
    public int Id { get; set; }
    public string FirstName { get; set; }
    public string Email { get; set; }
    public bool IsPremium { get; set; }
    public double Balance { get; set; }
}

Nested JSON → Nested C# Classes

Nested JSON objects generate separate C# classes with typed properties.

Input JSON

{
  "product": {
    "id": 1,
    "name": "Laptop",
    "specs": {"ram": 16, "storage": 512}
  }
}

Output CSV

public class Specs
{
    public int Ram { get; set; }
    public int Storage { get; set; }
}

public class Product
{
    public int Id { get; set; }
    public string Name { get; set; }
    public Specs Specs { get; set; }
}

public class Root
{
    public Product Product { get; set; }
}

Frequently Asked Questions