Skip to main content
AllDevToolsHub
💠

JSON to C# Class

100% Local

Convert JSON to C# classes with properties.

JSON to C# Class
using System; using System.Collections.Generic; using System.Text.Json.Serialization; namespace MyApplication.Models { public class Profile { [JsonPropertyName("firstName")] public string FirstName { get; set; } [JsonPropertyName("lastName")] public string LastName { get; set; } } public class Root { [JsonPropertyName("id")] public int Id { get; set; } [JsonPropertyName("user_name")] public string UserName { get; set; } [JsonPropertyName("isActive")] public bool IsActive { get; set; } [JsonPropertyName("score")] public double Score { get; set; } [JsonPropertyName("profile")] public Profile Profile { get; set; } [JsonPropertyName("roles")] public List<string> Roles { get; set; } [JsonPropertyName("metadata")] public object? Metadata { get; set; } } }
Try:
This tool runs entirely in your browser. Your input is never uploaded, logged, or sent to AllDevToolsHub or anyone else, and it keeps working offline once the page has loaded.

Paste JSON to generate C# classes with proper type mapping and nullable annotations.

Overview

What is JSON to C# Class?

Convert JSON into strongly-typed C# classes with inferred .NET types, PascalCase properties, nested classes, and System.Text.Json [JsonPropertyName] attributes.
FAQ

Frequently Asked Questions

Reference

Technical Deep Dive

CONVERTERS

JSON to C# Class

Convert JSON into strongly-typed C# classes instantly. It infers standard .NET types, converts properties to PascalCase, handles nested classes, and supports `[JsonPropertyName]` attributes from System.Text.Json to ensure mappings work flawlessly. You can also define an optional namespace to wrap your models.

🔁

Two-Way Conversion

Convert in either direction with consistent semantics on the round-trip.

🎯

Type-Faithful

Preserves nulls, numbers, booleans, and structure, no string-soup translation.

📦

Production-Sized

Built to handle real-world payloads, not just textbook examples.

01 Type Inference Matrix

JSON Type C# Type Generic Wrapper Attribute Logic
Integerint / long-Range detection
Floatdouble / decimal-Precision mapping
Stringstring-Standard mapping
ISO 8601DateTime-Auto-parsing support
ArrayList<T>T[]Homogeneous inference
NullT?Nullable Value TypesConditional mapping

02 Generation Pipeline

1
Schema Discovery The input JSON is parsed into an internal schema representation to identify data types, nesting depth, and optionality markers.
2
Naming Normalization Keys are converted to PascalCase for properties, while preserving the original JSON key mapping via serialization attributes.
3
Class Serialization The final C# source is emitted with necessary using directives, namespace wrappers, and recursive class definitions.

You Might Also Need