JSON to C# Class Converter
Json Code
Generated Entity
Paste JSON to generate annotated C# classes
JSON to C# FAQs
How to fix invalid property names?
Solutions:
1. Auto-convert: snake_case to PascalCase
2. Keywords: Prefix with @ (e.g. @class)
3. Sanitization: Remove $/- characters
4. Custom mapping: Configure field renaming rules
1. Auto-convert: snake_case to PascalCase
2. Keywords: Prefix with @ (e.g. @class)
3. Sanitization: Remove $/- characters
4. Custom mapping: Configure field renaming rules
How to handle date formats correctly?
Best practices:
1. Auto-detect: ISO8601/timestamp formats
2. Newtonsoft: [JsonProperty(ItemConverterType=typeof(IsoDateTimeConverter))]
3. System.Text.Json: [JsonConverter(typeof(JsonDateTimeConverter))]
4. Custom: Set DateTimeOffset and timezones
1. Auto-detect: ISO8601/timestamp formats
2. Newtonsoft: [JsonProperty(ItemConverterType=typeof(IsoDateTimeConverter))]
3. System.Text.Json: [JsonConverter(typeof(JsonDateTimeConverter))]
4. Custom: Set DateTimeOffset and timezones
How to process complex nested objects?
Approaches:
1. Auto-hierarchy: Generate separate classes
2. Collections: Smart List/IEnumerable selection
3. Circular refs: Add [JsonIgnore] attributes
4. Polymorphism: Generate [JsonDerivedType] (.NET 7+)
1. Auto-hierarchy: Generate separate classes
2. Collections: Smart List
3. Circular refs: Add [JsonIgnore] attributes
4. Polymorphism: Generate [JsonDerivedType] (.NET 7+)