# JSON to C# Class Converter

Convert JSON data into C# classes with PascalCase properties, JsonPropertyName attributes, and nested type inference

> Canonical page: https://elysiatools.com/en/tools/json-to-csharp

- **Category:** Development

- **Keywords:** json, csharp, c#, dotnet, class, convert, transform, codegen, json to csharp, JsonPropertyName, dto

## Overview

The JSON to C# Class Converter simplifies .NET development by instantly transforming raw JSON payloads into strongly-typed C# classes. It automatically infers nested types, generates PascalCase properties, applies JsonPropertyName attributes for seamless serialization, and supports nullable properties to match your API specifications.

## Inputs

- **JSON Input** (textarea): { "name": "Alice", "age": 30, "roles": \["admin", "user"\], "address": { "city": "Shanghai", "zip": "200000" } }
- **Root Type Name** (text): Root
- **Nullable Properties** (checkbox)

## When to use

- When integrating external REST APIs into a .NET application and you need to quickly generate Data Transfer Objects (DTOs).
- When modeling complex, deeply nested JSON payloads into structured C# classes without manual typing.
- When configuring System.Text.Json serialization with proper property mapping attributes and nullable type safety.

## How it works

- Paste your raw JSON payload into the JSON Input field.
- Specify the Root Type Name for your main class and toggle the Nullable Properties option if your API contains optional fields.
- Click convert to generate the C# class structure with PascalCase properties and JsonPropertyName attributes.

## Use cases

- Generating DTOs for HttpClient API integrations in ASP.NET Core projects.
- Creating configuration binding classes for appsettings.json files.
- Mapping third-party webhook payloads to strongly-typed C# models.

## Frequently asked questions

### Does the converter support nested JSON objects?

Yes, it automatically detects nested objects and arrays, generating separate, strongly-typed C# classes for them.

### What JSON serializer attributes are generated?

The converter generates JsonPropertyName attributes to map original JSON keys to PascalCase C# properties.

### Can I make the generated properties nullable?

Yes, enabling the Nullable Properties option adds the ? modifier to C# types to handle optional JSON fields.

### What is the default name of the main generated class?

The default root class name is 'Root', but you can customize this using the Root Type Name configuration field.

### Does this tool support C# record types?

The tool generates standard C# classes with properties, which can be easily adapted to records or structs in your codebase.

## Related tools

- [Data URI Generator](https://elysiatools.com/en/tools/data-uri-generator): Convert files into Data URIs (Base64 or percent-encoded) for inlining images, fonts, and assets directly into HTML, CSS, or Markdown
- [JSON Schema to Zod Schema Converter](https://elysiatools.com/en/tools/json-schema-to-zod-schema-converter): Convert JSON Schema JSON/YAML definitions into ready-to-use Zod schemas with nested objects, arrays, enums, and common validation rules
- [JSON to Go Struct Converter](https://elysiatools.com/en/tools/json-to-go): Convert JSON data into Go struct definitions with json struct tags, exported PascalCase fields, and nested type inference
- [JSON to Java Class Converter](https://elysiatools.com/en/tools/json-to-java): Convert JSON data into Java classes with Jackson @JsonProperty annotations, private fields, getters, and setters
- [JSON to Kotlin Data Class Converter](https://elysiatools.com/en/tools/json-to-kotlin): Convert JSON data into Kotlin data classes with @SerializedName annotations, nullable handling, and nested type inference
- [JSON to Rust Struct Converter](https://elysiatools.com/en/tools/json-to-rust): Convert JSON data into Rust structs with serde Serialize/Deserialize derives, snake_case fields, and serde rename attributes
- [JSON to TypeScript Converter](https://elysiatools.com/en/tools/json-to-typescript): Convert JSON data into TypeScript interfaces or type aliases with union types, optional fields, and nested object inference
- [Log Sequence Diagram Converter](https://elysiatools.com/en/tools/log-sequence-diagram-converter): Convert structured service logs into Mermaid or PlantUML sequence diagrams, with optional latency and error annotations

## Samples

- [Terraform Plan JSON Samples](https://elysiatools.com/en/samples/terraform-plan-json-samples): Sample Terraform plan JSON files exported from terraform show -json style payloads for dependency visualization and change review
- [Chat Transcript JSON Samples](https://elysiatools.com/en/samples/chat-transcript-json): JSON examples for multi-role chat transcripts
- [JSON Samples](https://elysiatools.com/en/samples/json): JSON (JavaScript Object Notation) format examples from simple to complex structures
- [Rich Media JSON Samples](https://elysiatools.com/en/samples/rich-media-json): JSON examples for popular rich text editors (TipTap, Quill, Slate)

## Related content

- [JSON to Typed Code Generators](https://elysiatools.com/en/hubs/json-to-typed-code-generators): Generate typed models from JSON or schema evidence for TypeScript, Go, Rust, Kotlin, Java, C#, and Zod validation workflows.
