JSON to Dart Class
Generate a Dart class from a JSON sample — typed fields, fromJson, and toJson.
class MyModel {
final int id;
final String name;
final String email;
final double score;
final bool active;
final List<String> tags;
final Address address;
const MyModel({
required this.id,
required this.name,
required this.email,
required this.score,
required this.active,
required this.tags,
required this.address,
});
factory MyModel.fromJson(Map<String, dynamic> json) => MyModel(
id: (json['id'] as num).toInt(),
name: json['name'] as String,
email: json['email'] as String,
score: (json['score'] as num).toDouble(),
active: json['active'] as bool,
tags: json['tags'] as List<String>,
address: Address.fromJson(json['address']),
);
Map<String, dynamic> toJson() => {
'id': id,
'name': name,
'email': email,
'score': score,
'active': active,
'tags': tags,
'address': address.toJson(),
};
}How JSON to Dart class generation works
Each JSON field is mapped to a typed Dart property: strings → String, integers → int, decimals → double, booleans → bool, arrays → List<T>, nested objects → nested classes. The generator creates a constructor with named required parameters, a fromJson factory, and a toJson method.
For TypeScript types from JSON, see JSON to TypeScript. For Go structs, try JSON to Go Struct. For Rust, see JSON to Rust Struct.
Private & free — this tool runs entirely in your browser.
Recommended: IndieKit — Ship your Next.js startup in days.affiliate
Related Converters tools
JSON to YAML
Convert JSON into clean, readable YAML instantly.
YAML to JSON
Convert YAML configuration into valid JSON.
JSON to CSV
Flatten a JSON array of objects into CSV rows.
CSV to JSON
Parse CSV with headers into a JSON array of objects.
JSON to XML
Convert JSON structures into nested XML markup.
JSON Minifier
Strip whitespace to produce compact JSON.
JSON to TypeScript
Generate TypeScript interfaces from a JSON sample.
JSON to SQL
Turn a JSON array of objects into SQL INSERT statements.