DevKits

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:

135 chars · 7 lines

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