Skip to main content

JSON to Dart

New

Generate Dart classes with fromJson/toJson helpers from JSON data.

convertdartflutter
Read the guide
Shortcuts:⌘ KSearch
Generates Dart models with fromJson and toJson helpers.

Frequently Asked Questions

Does it generate fromJson and toJson, or just fields?

It generates full model classes with a factory fromJson(Map<String, dynamic>) and a toJson() method.

If I paste an array, does it inspect every item?

No. Arrays use the first non-null item to decide the item type, and empty arrays fall back to List<dynamic>.

How are number conversions handled in fromJson?

int fields read through (value as num).toInt(), and double fields use .toDouble(). That avoids losing numeric JSON values that arrive as num.

Why are my Dart property names camelCase when the JSON keys are not?

Field names are camelCased for Dart style, but the generated json['original_key'] lookups and toJson output still use the original JSON keys.

What happens if the top-level JSON is a primitive or an array?

The tool emits a typedef for the root type, then any nested classes it discovered while analyzing the sample.

Related Tools