JSON to Dart Model Generator

Paste JSON, get Dart code instantly. Private, in your browser.

Input

Output

Ready
Ln 1, Col 1

Convert JSON to Dart in one step

Paste JSON and get null-safe Dart model classes with fromJson factories and toJson methods, ready to use in Flutter apps without extra packages.

How to use it

  1. Paste a JSON sample into the Input panel, open a file, or drop it onto the page. A sample is already loaded so you can see the result.
  2. The Dart code appears instantly in the Output panel and updates as you type.
  3. Rename the top-level type under Settings → Root type name, and use Sort keys to order fields alphabetically.
  4. Copy the code or Download it as Root.dart.

What the Dart generator produces

  • Immutable classes with final fields and a const constructor using named parameters.
  • required for fields present in every sample; nullable types (int?) otherwise.
  • fromJson handles nested objects, lists of objects and num-to-double conversion.
  • toJson converts nested models back to maps.

Using the generated Dart code

Parse a response with dart:convert:

import 'dart:convert';

final data = Root.fromJson(jsonDecode(body) as Map<String, dynamic>);
print(data.users.first.name);
final back = jsonEncode(data.toJson());

More JSON tools

All tools are free and run privately in your browser.

JSON to Dart FAQ

Do I need json_serializable or build_runner?

No. The fromJson and toJson code is written out in full, so the models have no dependencies and need no code generation step.

Is my data uploaded to a server?

No. The JSON to Dart runs entirely in your browser using JavaScript. Your data is never uploaded, logged or stored, and the tool keeps working offline after your first visit.