JSON to C# Class

Free. No sign-up. Your input is processed in your browser.

Paste sample JSON and get C# classes.

How to use it

  1. Paste a sample of your JSON or XML.
  2. Keep C# selected and enter a class name if you like.
  3. Copy the classes and check the types.

How types are chosen

Whole numbers become int or long, and numbers with a decimal point become double. Use decimal instead for money. A field missing from some list items, or set to null, becomes nullable. Names that differ from C# style get [JsonPropertyName].

Limits

Types come from your sample only. A larger sample gives a better result. Attributes are for System.Text.Json, not Newtonsoft.Json.

Questions

What happens with very large numbers?

Numbers beyond the long range become decimal, with a warning. Check that it is large enough for your data.

Can I use XML?

Yes, but XML has no data types, so values become strings.

Related tools

See all tools