JSON to C#ONLINE

Generate C# types or models from sample JSON and download .cs code.

1 MiB per input · Ctrl / ⌘ + Enter to run

quicktype infers shapes from a sample up to 128 Ki characters. Review field optionality, names, and type choices before adding generated code to your project.

Result
Ready. Paste input, then run the tool.
Your JSON stays in your browser. Core processing happens locally.
THE PRACTICAL GUIDE

Generate C# models that map JSON property names deliberately

JSON to C# turns a sample document into a draft model for .NET code. It helps start data transfer classes when an API contract is not yet written down.

When should you use it?

  • Create a draft response model for a C# client.
  • Review nested JSON properties as typed members.
  • Prepare a fixture-backed DTO for a prototype.
WORKED EXAMPLE

Example: infer C# fields from JSON

This abbreviated example shows the inferred name and active fields in C#. The full generated file includes imports and helpers and may change with generator versions; review it before adding it to a project.

Sample JSON
{"name":"Alex","active":true}
Illustrative model excerpt
public partial class Root {
    [JsonPropertyName("name")]
    public string Name { get; set; }
    [JsonPropertyName("active")]
    public bool Active { get; set; }
}

Keep wire names and C# names in agreement

A JSON property such as display_name may become a more idiomatic C# member name. Serializer attributes or naming configuration preserve the connection to the original wire name. Review the generated attributes and serializer helpers together, especially when moving the model into an application that already has a global naming policy.

Review nullability with the real response contract

A non-null value in one sample does not establish that the property can never be missing or null. Check reference and value types under your project nullability settings, then test deserialization with representative payloads. Date strings and large numeric values also deserve an explicit choice. Generated models are a starting point for that review, not evidence that the service contract is complete.

IN PRACTICE

How do I generate C# classes for a JSON API response?

Generate .cs source from the sample and inspect the properties plus serialization attributes. The current quicktype C# target includes System.Text.Json mapping code, but you still need to review how your application handles missing and null fields.

Illustrative C# property mapping

csharp
public partial class Root
{
    [JsonPropertyName("name")]
    public string Name { get; set; }
}

The generated file contains additional members and imports. Check nullable reference type settings and numeric widths before using the model.

It infers from the supplied sample, not the complete server contract. Test records with absent or null fields and adjust types and defaults deliberately.

BEFORE YOU USE THE RESULT

What should you check before using the result?

Review naming, nullability, numeric widths, and serializer settings against your .NET project. Inferred types are only as representative as the sample.

Understand JSON syntax

Technical reference: quicktype model generation documentation

THE JSON FIELD GUIDE
All guides