/tools/json-to-csharp

JSON to C# Converter

Generate C# 12/.NET 8 records or classes with nullable types and System.Text.Json aliases.

json-to-csharp://local

JSON sample

C# output

Ready. Paste representative JSON to infer C# types locally.

/usage

Generate .NET models from JSON

  1. Paste representative JSON or choose a local file.
  2. Select records or classes and serializer-ready or framework-neutral output.
  3. Generate, review nullable and mixed types, then copy or download the .cs file.

/output

C# models that retain JSON evidence

Modern defaults

The generator emits #nullable enable, C# records and .NET 8-friendly collection types.

Exact JSON names

[JsonPropertyName] preserves original keys when generated property names differ.

Missing and null fields

Nullable value and reference types make optional evidence visible rather than assigning unsafe defaults.

Mixed-type warning

Irreducible unions use JsonElement and surface a warning for operator review.

/faq

JSON to C# questions

Which .NET version is targeted?

The defaults target C# 12 and .NET 8 with System.Text.Json.

Does it upload the JSON?

No. Parsing, inference and C# emission happen inside a dedicated local browser worker.

Are all array items inspected?

Yes, within bounded traversal limits. Missing fields, explicit nulls and differing item types all contribute evidence.