Skip to content
{ }JSON Formatter

JSON to C# Converter

Generate C# classes from a JSON sample — PascalCase properties, nested classes and typed collections for System.Text.Json or Newtonsoft.

Input
Output
Paste input and press Generate C#.

Paste JSON, get the class model

Whether you're consuming a REST API in ASP.NET, reading configuration, or binding a webhook payload — .NET wants classes. The generator infers them from your sample: PascalCase properties per C# convention, one class per object shape, List<T> for arrays, and sensible numeric types (long/double) where JSON leaves width unspecified.

System.Text.Json and Newtonsoft both welcome

The output is deliberately plain — properties without library-specific attributes — so it deserializes with modern System.Text.Json (add PropertyNameCaseInsensitive = true, or a naming policy for camelCase APIs) and with classic JsonConvert.DeserializeObject<T>() alike. Where a single wire key can't map cleanly, one [JsonPropertyName("…")] on that property does it — the rest of the model stays generated.

From sample to solution

The sample defines the model: nulls become nullable types, fields missing from some array entries are treated as optional, and mixed types fall back to object (a signal to look at your API, not your code). Feed a representative response — grab one with the cURL generator, prettify it in the formatter, then generate here.

Frequently asked questions

Does the output target System.Text.Json or Newtonsoft.Json?

Both — the classes are attribute-free POCOs. With System.Text.Json set PropertyNameCaseInsensitive (or a camelCase naming policy) since APIs usually send camelCase; Newtonsoft is case-insensitive by default.

Why did camelCase keys become PascalCase properties?

.NET naming conventions — properties are PascalCase in virtually every C# style guide. The serializer bridges the difference via naming policy or per-property [JsonPropertyName].

How are nullable values represented?

null in the sample produces nullable types (double?, string with nullable annotation contexts). Fields that are always null cannot be inferred beyond object — provide a richer sample.

Can it produce C# records?

It generates classic classes for the broadest compatibility. In a modern codebase, converting to records is a quick mechanical edit — the property list and types are the generated value.