>_devtools

JSON to Dart Class Converter

Generate Dart classes from a JSON sample, with final fields, required parameters, and copyWith.

What this does

Generates Dart model classes from a JSON sample, the usual first step when wiring an API into a Flutter app. Each nested object becomes its own class with a constructor, and property names are converted to lowerCamelCase.

Example

Input

{
  "id": 42,
  "name": "Ada",
  "verified": true,
  "tags": [
    "admin",
    "dev"
  ],
  "orders": [
    {
      "sku": "A1",
      "qty": 2
    },
    {
      "sku": "B2",
      "qty": 1,
      "note": "gift"
    }
  ]
}

Output with default options

class Root {
    final int id;
    final String name;
    final bool verified;
    final List<String> tags;
    final List<Order> orders;

    Root({
        required this.id,
        required this.name,
        required this.verified,
        required this.tags,
        required this.orders,
    });

}

class Order {
    final String sku;
    final int qty;
    final String? note;

    Order({
        required this.sku,
        required this.qty,
        this.note,
    });

}

How values are mapped

  • Whole numbers become int, other numbers double, strings String, booleans bool.
  • Arrays become List<T>; a field missing from some objects becomes T? and is not required in the constructor.
  • ISO 8601 timestamps become DateTime when date detection is on.
  • Always-null values and mixed-type arrays fall back to dynamic.

Options

Keep properties final, mark constructor parameters required, and add acopyWith method. With Types only turned off, each class also gets fromJson and toJson (using dart:convert), orjson_annotation support if you tick that box.

Things to know

The generated classes mirror your sample, so paste a few representative objects. For large projects you may prefer code generators like freezed; this tool is meant for getting an accurate starting model quickly.

Privacy

Generation runs in a Web Worker in your browser. The JSON is never uploaded.