JSON to Dart
Null-safe Dart models with fromJson and toJson, ready for Flutter.
About this tool
Paste JSON and get Dart classes you can drop straight into a Flutter or Dart project, with no build_runner or json_serializable step.
How the Dart is generated
Each JSON object becomes a class with final fields, a const constructor with required named parameters, a fromJson factory and a toJson method. Keys become camelCase fields (user_name โ userName) while fromJson and toJson keep the original keys. Nested objects call their own fromJson, lists are mapped item by item, whole numbers are int and decimals double. Decimals are read through num, so both 12 and 12.5 work. Array items are merged before types are chosen, so a key that only some items have, or that is sometimes null, is treated as optional or nullable rather than breaking decoding. Those become nullable and optional in the constructor. Honest limits: types describe your sample, always-null values become dynamic, and dates stay as String. For large projects, json_serializable or freezed may suit better. JSON to Swift, JSON to Kotlin and the JSON formatter are related.
Frequently asked questions
How do I convert JSON to a Dart model?
Paste the JSON here and copy the classes. Use User.fromJson(jsonDecode(body)) to parse.
Do I need json_serializable or build_runner?
No. The fromJson and toJson methods are written out in full.
Why read numbers via num?
JSON doesn't distinguish 12 from 12.0, so reading as num and calling toDouble() avoids type errors.
Is my JSON uploaded?
No. Everything runs in your browser and nothing is stored or sent.