JSON to Dart Class Generator (Flutter)
Turn JSON into null-safe Dart model classes for Flutter with fromJson/toJson, or json_serializable annotations. Nested classes and lists included.
dynamic is used where every sample was null or where samples mix different kinds of values — replace it with the real type once you know it.
A number written as 10.0 is read as a whole number, so a field whose samples are all like that becomes int — include one sample with a fraction to get double.
Flutter apps decode JSON into Dart model classes, and writing them by hand — fields, a constructor, fromJson and toJson — is slow and easy to get wrong. Paste a sample API response and get null-safe Dart classes: nested objects become their own classes, arrays become List<T>, fields that are null or missing in some samples become nullable (T?), and snake_case keys become camelCase fields that still read the right JSON key. Choose hand-written fromJson/toJson with no packages, or json_serializable annotations for code generation.
How to use this tool
- Paste a representative JSON sample — an array with several items gives the most accurate types.
- Enter the root class name.
- Pick hand-written fromJson/toJson, json_serializable or fields only.
- Decide whether fields are nullable only when needed or always, and whether ISO date strings become DateTime.
- Copy the code into a .dart file (for json_serializable, run build_runner).
Formula
whole number → int · fraction → double · true/false → bool · text → String · ISO date → DateTime · [ … ] → List<T> · { … } → class
Values seen at the same place are merged: int and double become double (read through num, so a JSON 1 does not fail the cast), mixed kinds become dynamic. A field that is null in some sample or missing from some array item is nullable. Identical object shapes share one class; list item classes are named from the singular of the key (orders → Order). Names that clash with Dart keywords or dart:core types get a suffix (class → classValue, Map → MapModel).
Example
The sample user gives three classes. User has final int id, String name, String email, bool isActive (from is_active), double balance, DateTime createdAt, List<String> tags, Address address, List<Order> orders and dynamic manager (null in the sample). Order has String orderId, double total (59.9 and 12 merge to double), int items and String? coupon — nullable because only the second order has one. fromJson reads json['order_id'], and toJson writes createdAt with toIso8601String().
Frequently asked questions
Hand-written or json_serializable?
Hand-written fromJson/toJson needs no packages and no build step, which suits small models. json_serializable generates the same code from annotations with build_runner; it is easier to maintain when models change often.
Why is a field typed dynamic?
Every sample was null, or the samples mix kinds such as numbers and text. Paste a sample with a real value, or set the type by hand.
Why does a double field use (json['x'] as num).toDouble()?
JSON does not distinguish 12 from 12.0, so jsonDecode returns an int for whole numbers. Casting straight to double would throw; going through num accepts both.
Is my JSON uploaded?
No. The classes are generated in your browser.
Sources
Last updated:
Page address with these inputs: https://kakao.mobile/tools/json-to-dart-pojo-generator/
Cite or embed this tool
kakaoCalc. (2026, November 8). JSON to Dart Class Generator (Flutter). https://kakao.mobile/tools/json-to-dart-pojo-generator/
“JSON to Dart Class Generator (Flutter).” kakaoCalc, 8 Nov. 2026, kakao.mobile/tools/json-to-dart-pojo-generator/.
Paste this code into your page. The widget runs in your visitors' browsers, shows no ads and keeps a link back to this page. Embedding terms