What is JSON to C# Class Generator?
This tool converts JSON data into C# class definitions with proper type inference. It generates properties with { get; set; } accessors, converts field names to PascalCase following C# conventions, supports nullable reference types, and can add System.Text.Json attributes for JSON serialization.
How to Use
- Set the root class name and configure options (nullable types, System.Text.Json attributes, date detection)
- Paste your JSON data into the input area
- Click "Generate C# Classes" and copy the output into your C# project
Why Use This Tool?
Tips & Best Practices
- Use realistic sample data — type inference depends on actual values
- Enable nullable types for modern C# projects (C# 8.0+)
- System.Text.Json attributes ensure JSON keys match original names even after PascalCase conversion
- Null values in JSON are converted to nullable types (int?, double?, etc.)
Frequently Asked Questions
How are JSON types mapped to C#?
JSON strings → string, integers → int, floats → double, booleans → bool, null → T? (nullable), arrays → List<T>, objects → separate nested classes. ISO-8601 date strings can be detected as DateTime when the option is enabled.
Why use PascalCase for property names?
C# convention requires public properties to use PascalCase. This tool automatically converts camelCase, snake_case, or kebab-case field names to PascalCase while preserving the original JSON key in the JsonPropertyName attribute.
What does the "Nullable types" option do?
When enabled, value types (int, double, bool, DateTime) are generated as nullable (int?, double?, bool?, DateTime?) for fields that may have null values. This is useful for APIs where fields can be omitted or null.
What are System.Text.Json attributes?
The [JsonPropertyName("key")] attribute tells System.Text.Json to map a C# property to a specific JSON key. This is essential when C# PascalCase property names differ from the original camelCase JSON keys.
Is my data sent to a server?
No, all processing happens entirely in your browser. Your JSON data never leaves your device.