How to Convert JSON to Csharp Class: Steps and a Worked Example
Generate a C# class with properties from a sample JSON object. This guide shows what to enter, a worked example, and the limits to keep in mind. The JSON to Csharp Class tool is free, needs no account and runs in your browser.
What you need
- JSON, for example {"id":42,"name":"Ana","active":true}
Step by step
- Open the JSON to Csharp Class tool.
- Fill in JSON.
- Read the result, which updates as soon as the inputs change.
Worked example
With these inputs:
- JSON: {"id":42,"name":"Ana","active":true}
the tool returns:
public class Root {
public double Id { get; set; }
public string Name { get; set; }
public bool Active { get; set; }
}
How it works
Paste a JSON object. Property names are capitalised and types are inferred from the values.
Things to keep in mind
Check your inputs, units and any local rules before you rely on the result.
Related tools
If this is not quite what you need, try JSON to Kotlin Data Class, JSON Formatter or JSON Validator.