JSON to C# Class

developer

Auto-generate C# class definitions from JSON. Supports nullable types, JsonPropertyName attributes, nested classes and namespaces.

#json#csharp#c##.net#class#model#dotnet#developer
Loading tool...

How to use

  1. 1Paste your JSON object into the input
  2. 2Set the root class name and namespace
  3. 3Choose whether to use nullable types and JsonPropertyName attributes
  4. 4Click "Process" to get ready-to-use C# class definitions

Frequently Asked Questions — JSON to C# Class

How are C# types inferred?+

JSON numbers → int or double, booleans → bool, strings → string (DateTime if format matches), null → object?, arrays → List<T>, objects → separate classes.

What is [JsonPropertyName] used for?+

When JSON keys use snake_case (like first_name) but C# properties need PascalCase (FirstName), [JsonPropertyName("first_name")] ensures correct serialization/deserialization.

Does this use System.Text.Json or Newtonsoft?+

System.Text.Json (built-in since .NET Core 3.0+). Add `using System.Text.Json.Serialization;` at the top.

What about nullable reference types?+

Enable "Use nullable types" to add ? to properties like string? and int?. Recommended if your project has nullable reference types enabled (#nullable enable).

Related Tools