JSON to C# Class
Convert JSON to a C# class with auto-implemented properties. Detects primitive types, lists, arrays and nested objects. Useful for .NET/Unity. Everything in your browser.
Model an API response as .NET classes
You are about to consume an API from .NET and you need the classes that System.Text.Json or Newtonsoft will fill in. It is mechanical work, and it is exactly where the expensive mistake slips through: a money value typed as an integer, a list left out entirely. Paste a sample payload and get back a class with auto implemented properties and nested objects already split into their own classes.
Types come from values: text becomes string, true or false becomes bool, a whole number becomes long, a decimal number becomes double, null becomes object, and an array becomes a List of the first element's type. The meaningful difference from the Java generator is naming: here properties are converted to PascalCase, so first_name becomes FirstName. That matches C# convention but breaks deserialisation against snake_case JSON unless you configure something.
Before this goes into your project: if the field is money, swap double for decimal, because double rounds in binary and you do not want that on an invoice. Nullability is not annotated, so add the question mark wherever the contract allows null. Two keys with the same name at different points in the JSON produce a single class, whichever came first. An empty array becomes a List of object for lack of a sample. Conversion happens in your browser.
Frequently asked questions
How do I match properties against snake_case JSON?
Is this usable in Unity?
What if the sample array is empty?
Related Tools
JSON to Java Class
Convert JSON to a Java POJO class with getters/setters and inferred types. Supports nested classes and arrays as List. Everything in your browser.
JSON ⇄ Query String Converter
Convert a flat JSON object to a query string (?a=1&b=2) and vice versa. Supports a[]=1&a[]=2 array style. Everything in your browser.
BSON to JSON (text) Converter
Explains differences between binary BSON and JSON with a type table and textual conversion examples.
YAML to NDJSON Converter
Explains how to represent YAML lists as NDJSON (one JSON object per line) with practical examples.
JSON to TypeScript
Convert a JSON to TypeScript interfaces with automatically inferred types. Detects strings, numbers, booleans, arrays, nested objects and union types. Everything in your browser.
YAML to JSON
Convert YAML data to JSON format.