C# Class to JSON Schema Generator

Need JSON to C#?

Produce C# models with attributes directly from JSON.

JSON → C# Classes

C# code Input

Loading...

JSON Schema Output

Paste your C# DTOs to produce a JSON Schema instantly.

Supports classes, structs, records, annotations, nullable reference types, and generic collections.

Frequently Asked Questions

Which C# constructs are supported?

The parser understands classes, structs, records (with primary constructors), auto-properties, backing fields, enums, and attributes such as JsonPropertyName, JsonProperty, and DataMember(Name=...). It respects nullable reference types, optional fields, collections, and dictionaries directly in the generated schema.

How are types mapped to JSON Schema?

Primitives such as string, bool, int/double/decimal, DateTime/DateOnly/Guid map to the closest schema type and format. Arrays, List<T>, IEnumerable<T>, Dictionary<TKey, TValue>, Nullable<T>, and T? are converted into array/object/optional schema constructs. Unrecognized symbols fall back to references when they match another class or enum.

Does it work with different C# versions and serializers?

Yes. Modern features like records, init-only setters, nullable reference types, System.Text.Json annotations, and classic Newtonsoft.Json attributes are handled. The tool runs completely in your browser, so you can safely paste proprietary DTOs or API contracts.

How can I generate mock JSON?

After the schema is created, click "Generate Mock Data" to open the Mock Generator with your schema preloaded. Configure locales, array counts, and optional fields to instantly produce realistic payloads for docs or tests.