Paste JSON
Upload File

Click to select or drag & drop a .json file

What the generator decided

Paste or upload JSON to see every type decision laid out — which field became which C# type, which key was renamed because it was not a valid C# identifier, and which array was inferred as a concrete class versus List<object>.

All generation runs in your browser. Your JSON is never uploaded to any server.

JSON to C# Converter

Turn any JSON into C# class definitions directly in your browser — no upload, no API call, no tracking. Paste JSON (or drop a .json file) and get C# classes with nested types, lists, nullable reference types, and a full type-decision report that shows exactly how each field was inferred.

What it generates

Why the report matters

Most generators hand you a class and stay silent about the guesses. This one doesn't. For every field it tells you the inferred type. For every renamed key it shows the original and the reason. For every array it tells you whether the element type was pinned to a concrete class or fell back to List<object> because the elements varied. That is the difference between a class you can trust and one that quietly deserializes wrong.

Using the output

Copy the code into a .cs file. With [JsonPropertyName] enabled (default), deserialize with System.Text.Json:

The attribute on each property preserves the original JSON key, so the generated class round-trips your data even when property names were changed.

How inference works (and its limits)

Array element types are inferred from the first element of each array; if the elements have differing shapes, the array falls back to List<object>

FAQ

Is this JSON to C# converter free?

Yes. It runs entirely in your browser, with no login, no usage limits, and no ads on this tool. Your JSON never leaves your device.

Is my JSON data safe?

Yes. All code generation happens locally in JavaScript. Your JSON is never sent to a server, logged, or stored. You can disconnect from the internet after the page loads and it will still work.

What if my JSON keys have spaces or special characters?

Keys that are not valid C# identifiers (spaces, hyphens, dots, leading digits, or reserved words like class) are renamed to clean property names. The original key is preserved through a [JsonPropertyName("original")] attribute, and the report lists every rename so nothing is hidden.

How are arrays handled?

An array of objects becomes List<ElementClass> (or ElementClass[]). An array of primitives becomes List<string>, List<int>, etc. If the array's elements have different shapes, it becomes List<object> — the report flags this so you know the type was not pinned down.

Does it support nullable reference types?

Yes, when the "Nullable" option is on (default). Fields whose sample value was null are emitted as nullable (string?, object?, …). Turn the option off for a non-nullable variant.

Can I convert C# back to JSON?

This tool goes JSON → C#. For the reverse direction, use the CSV to JSON converter for tabular data, or your editor's built-in JSON support for C#.