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:
CommentsPaste 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.
Try Next
JSON → Go
Convert JSON to Go structs online. Generates idiomatic Go structs with proper json tags and PascalCase field names.
Related Tools
JSON → YAML
Convert JSON to YAML online. Preserve structure, comments-free, and ready to paste into Kubernetes or CI configs.
YAML → JSON
Convert YAML documents to JSON online. Supports YAML 1.2, multi-document streams, and produces pretty-printed JSON output.
JSON → CSV
Convert an array of JSON objects to CSV online. Headers are inferred automatically from all keys across records.
CSV → JSON
Convert CSV data to a JSON array of objects online. Auto-detects delimiter and quotes, preserves numeric types when requested.
Number Base
Convert numbers between binary, octal, decimal, and hexadecimal. Supports arbitrarily large integers using BigInt.
JSON → TypeScript
Convert JSON to TypeScript interfaces instantly. Generate strongly-typed TS types from any JSON sample.