JSON to C# Converter

Generate nested C# models and System.Text.Json converters, with nullable types inferred from null and missing sample fields.

How to generate C# models

Use a root name such as OrderResponse. Inspect the generated .cs files separately, or download the ZIP when your payload produces several types.

Complete output uses System.Text.Json. Use a .NET 8 or later project for the generated helper code. JsonPropertyName attributes preserve JSON names such as first-name; models-only output omits serialization mappings.

Samples, optional fields and limits

Keep strings as strings when preparing C# samples, even for IDs, dates and UUIDs. Treat the result as a model inferred from examples. Limits are 200,000 input characters, 64 nesting levels, 50 samples, 50 files and 1,000,000 output characters. The local worker can be cancelled and has a 10-second deadline.

Questions & answers

How should I sample missing and null fields for C#?

Compare a missing property with an explicit null by pasting both payloads as JSON Lines. Review the generated nullable annotations and add a populated example for a field that is always null.

Does the page run my generated C#?

C# source is generated from the pasted samples in the browser. It is not executed, and nothing is sent to a schema service.

Other Languages

JSON to C# Converter — Base64.sh

JSON to C# Converter

Generate nested C# models and System.Text.Json converters, with nullable types inferred from null and missing sample fields.

Share:

References

How we make sure

We check this tool with the automated test suites linked below. Example checks are shown in their original language.

Verification method
Check generated C# nullable types, nested classes and System.Text.Json names against fixed JSON fixtures.
Comparison reference
Explicit declaration/field-mapping assertions and generator integration.
Verification scope
These cases are not all claimed to invoke the target-language compiler.
Test source and cases (select a file to read it)
  • code-tools.test.js
    • JSON to C# infers nullable values, nested classes and System.Text.Json property names

These checks cover the listed examples and boundaries, not every possible input. Round trips and checks using the same library are not independent verification.