JSON to Dart

Generate Dart model classes from JSON with fromJson and toJson, null safety and nested lists. No build_runner needed.

How to convert JSON to Dart

  1. Paste a JSON object or array, for example a response from the API you are calling.
  2. Set the name of the root type.
  3. Copy the generated Dart code into your project.

What you get

Tips for accurate results

The generator only knows the sample you paste. Include arrays with several items and responses where optional fields are present, so it can tell which keys are always there, which can be null and which numbers have decimals.

Frequently asked questions

Is my JSON sent to a server?

No. The code is generated in your browser, so API responses and other private data never leave your device.

How do I use the classes in Flutter?

Decode the response with jsonDecode(response.body) and pass the map to Root.fromJson(...). To send data back, call jsonEncode(value.toJson()).

Why not json_serializable?

json_serializable needs annotations and a build_runner step. The generated classes contain the conversion code directly, so you can paste them and use them right away.

How are numbers handled?

Whole numbers become int. If any sample has decimals the field becomes double, read with (json[key] as num).toDouble() so values like 10 still decode correctly.