JSON to C# Class Converter (System.Text.Json)
Convert JSON to C# classes with System.Text.Json [JsonPropertyName] attributes, PascalCase properties, List<T> for arrays, and optional namespace. Works in .NET 6 / 7 / 8 / 9. 100% local.
Last updated:
Paste JSON to generate C# classes with System.Text.Json [JsonPropertyName] attributes, PascalCase properties, List<T> for arrays, and optional namespace. Works in .NET 6 / 7 / 8 / 9. 100% local.
Tips & Best Practices
- ▸For Newtonsoft.Json, replace [JsonPropertyName("x")] with [JsonProperty("x")] and swap the using directive.
- ▸For C# records, replace 'public class Foo { … }' with 'public record Foo(Type1 F1, …);' — the property types are already right.
- ▸Enable STJ source generation for AOT / trim-safe scenarios — the generated classes are compatible.
Frequently Asked Questions
Which JSON library is the output tuned for?
System.Text.Json — the stdlib serializer in .NET 6+. [JsonPropertyName("...")] annotations preserve the original JSON key names when the C# property name differs.
How do I switch to Newtonsoft.Json?
Replace `[JsonPropertyName("x")]` with `[JsonProperty("x")]` and swap the `using System.Text.Json.Serialization;` import for `using Newtonsoft.Json;`. Everything else is drop-in.
Can I generate C# records instead of classes?
The current output emits classes with get/set properties for maximum tooling compatibility. For records, replace `public class Foo { … }` with `public record Foo(Type1 Field1, …);` — the property types are already correct.
Is my JSON uploaded anywhere?
No. All conversion happens locally in your browser.
Related Tools
JSON → TypeScript
Convert JSON to TypeScript interfaces instantly. Generate strongly-typed TS types from any JSON sample.
JSON → Go
Convert JSON to Go structs online. Generates idiomatic Go structs with proper json tags and PascalCase field names.
JSON → Python
Convert JSON to Python @dataclass definitions with typed fields. snake_case field names, nested classes, List[T] for arrays, and JSON-key alias comments. 100% local.
JSON → PHP
Convert JSON to PHP 7.4+ classes with typed properties. Generates one class per nested object, phpdoc @var array<T> for typed arrays, and camelCase property names. 100% local.
JSON → Java
Convert JSON to Java POJOs with Jackson @JsonProperty annotations, camelCase field names, List<T> for arrays, and generated getters/setters. Optional package declaration. 100% local.
JSON → Rust
Convert JSON to Rust structs with #[derive(Serialize, Deserialize)]. snake_case field names, #[serde(rename)] for mismatched keys, Vec<T> for arrays, and reserved-keyword raw identifiers. 100% local.