Dart Class to JSON Schema Generator

Need JSON to Dart?
JSON → Dart Classes

Dart code Input

Loading editor…

JSON Schema Output

Settings

Select which class should be treated as the JSON Schema root.

Parsing runs entirely in your browser. Your source never leaves the page.

Paste your Dart models to produce JSON Schema instantly.

Supports typed fields, nullable types, List<T>, Map<String, T>, and nested classes.

How to convert Dart classes to JSON Schema – step-by-step guide

This online Dart class to JSON Schema converter helps you generate JSON Schema from real models (DTOs, structs, and classes) so you can validate payloads, share contracts, and generate mock JSON.

  1. Step 1 – Paste your Dart source

    • Paste the models you want to document into the left editor.
    • Include referenced types in the same snippet so the schema can generate definitions.
    • Use the Sample button to load an example and see the expected input format.
  2. Step 2 – Select the Root class (if needed)

    • If multiple definitions are detected, choose the root that matches your API payload.
    • The output schema is built around the selected root and may include additional definitions for referenced types.
  3. Step 3 – Review the JSON Schema output

    • Check types, required vs. optional fields, and nested object/array structures.
    • Look for definitions and $ref when your models reference other models.
    • Copy or download the schema for validation, documentation, or schema-first development.
  4. Step 4 – Validate or generate mock JSON

    • Click Generate Mock Data to open the mock generator with your schema preloaded.
    • Validate real payloads against your schema to catch breaking changes early.
    • If you rely on advanced schema composition (for example anyOf/oneOf/allOf), verify the result with a full validator like Ajv.

Schema keyword support note

Generated schemas can include $ref and may be edited to include anyOf, oneOf, or allOf. For complex schemas, use a full JSON Schema validator and dereference before mock generation if needed.

Related JSON Schema & code generation tools

Use these tools to validate schemas, generate mock payloads, format JSON examples, and keep code and contracts in sync.

Frequently Asked Questions

Which Dart features are supported?

The converter reads classes with typed fields, including nullable types (String?), List<T>, Map<String, T>, and nested classes. It ignores methods and constructors so you can paste plain Flutter models or freezed-generated classes.

How are Dart types mapped to JSON Schema?

Primitive types like String/Int/Double/Bool map directly to JSON primitives. Nullable types become optional fields, List<T> becomes schema arrays, Map<String, T> becomes objects, and dynamic/object default to 'any'.

Does it run locally?

Yes. Everything runs inside your browser—no source code leaves your machine. Use the sample button to see a quick demo.

How do I produce mock JSON?

After generating the schema, click "Generate Mock Data" to open the Mock Generator with the schema preloaded. Configure locales, array sizes, and optional fields to create realistic payloads.

Convert Dart Classes to JSON Schema Online | JSONSwiss