#️⃣

JSON to C# Class

Generate C# classes with properties from any JSON object.

Input
C# Class

📖 What is JSON to C# Class?

JSON to C# generates strongly-typed C# class definitions from a JSON sample. Paste any JSON and get ready-to-use C# classes with proper property types (string, int, bool, List, nested classes). Use it when consuming REST APIs, deserializing JSON with System.Text.Json or Newtonsoft.Json, or building DTOs for your .NET project. Everything runs in your browser.

💡 Example

Input
{"name":"Alice","age":30,"active":true,"tags":["dev","admin"]}
Output
public class Root { public string Name { get; set; } public int Age { get; set; } public bool Active { get; set; } public List<string> Tags { get; set; } }

🛠️ Common Use Cases

  • Generating DTOs from REST API response samples
  • Creating model classes for System.Text.Json or Newtonsoft.Json deserialization
  • Building request/response models for ASP.NET Web API projects
  • Scaffolding Entity Framework models from JSON data
  • Converting API documentation examples into C# code

📝 Type Mapping

  • JSON string → string
  • JSON number (integer) → int or long
  • JSON number (decimal) → double
  • JSON boolean → bool
  • JSON null → object (nullable)
  • JSON array → List<T>
  • JSON object → nested class

⚠️ Common Mistakes

  • Using sample data with wrong types — if a field is 0 in your sample, it maps to int even if it can be a decimal. Use representative sample data.
  • Forgetting nullable types — fields that can be null in the API should use nullable types like int? or string?
  • Property naming — C# uses PascalCase by convention. Add [JsonPropertyName("original_name")] attributes if the JSON uses snake_case.

❓ Frequently Asked Questions

Does it handle nested objects?
Yes — nested JSON objects generate separate C# classes that are referenced as properties in the parent class.
Which JSON library should I use?
For .NET 6+ use the built-in System.Text.Json. For older .NET or advanced features, use Newtonsoft.Json (Json.NET).
How do I handle snake_case JSON keys?
Add [JsonPropertyName("snake_case_name")] attributes to your properties, or configure a naming policy in your serializer options.
Is my data private?
Yes — all processing runs entirely in your browser. Your data is never sent to any server.
Is this tool free?
Completely free — no login, no usage limits, works offline once loaded.
Yes — completely free, no login required, no usage limits.
Is my data private?
Yes — all processing runs in your browser. Your data is never sent to any server.
Does it work offline?
Yes — once the page is loaded, the tool works without an internet connection.
🔒
Your data stays private. All processing happens entirely in your browser using JavaScript. Nothing is ever sent to our servers. You can even use this tool offline after the page loads.