JSON to Dart Class Generator

Private
Output
Examples:

Last updated: 2026-09-17

Paste a JSON object and get a Dart model class with named constructor parameters, a fromJson factory, and a toJson method. Null safety is enabled by default — nullable fields (null values in the JSON) get the ? suffix. Nested objects become separate Dart classes. Everything runs in your browser.

Dart naming conventions

The converter preserves JSON key names as-is in field names and fromJson/toJson. If your JSON uses snake_case keys, the Dart fields will also be snake_case. You may want to rename them to camelCase and add @JsonKey annotations for json_serializable.

Int vs double

JSON numbers without decimal points are typed as int. If a field might contain both integers and floats (e.g. “score”: 95 vs “score”: 95.5), you should manually change the type to num or double.

Frequently asked questions

How are null values handled?
When null safety is enabled, fields with null values in the JSON get the Dart nullable type suffix (?). Fields with non-null values are non-nullable and use the required keyword in the constructor. When null safety is disabled, all fields are non-nullable and no required keyword is used.
Are fromJson and toJson generated?
Yes by default. The fromJson factory takes a Map<String, dynamic> and maps each key to the corresponding field. The toJson method returns a Map<String, dynamic> with all fields. You can disable method generation if you only need the class structure.
How are nested objects handled?
Nested JSON objects become separate Dart classes. For example, {"profile": {"age": 30}} generates a Profile class and the parent class has a field of type Profile. The class name is derived from the field name capitalized and appended to the parent class name.
What about arrays of objects?
Arrays of objects produce List<ClassName> fields, and the converter generates the nested class for the array element type. Arrays of primitives produce List<String>, List<int>, List<double>, or List<bool>.
How are numbers typed?
Integer values become int, and floating-point values become double in Dart. Since JSON does not distinguish between integers and floats, the converter checks whether the value has a decimal point. Mixed numeric arrays fall back to List<num>.

Related converters