🚀 JSON to Dart Model Generator
Generate high-quality, production-ready Dart model classes instantly!
Whether you're starting with raw JSON or URL query parameters, this extension handles the heavy lifting of boilerplate generation.
✨ Features
📦 Post Model from JSON
Generates a full Equatable model with copyWith, toMap, fromMap, toJson, and fromJson. Perfect for request bodies!
🔗 Response Model from JSON (Single)
Handles API responses with a wrapper class and recursive nested object parsing.
📑 Response Model from JSON (List)
Optimized for paginated results. Includes a wrapper for metadata and a List of typed Data items with int.tryParse safety.
🔍 Query Params to Post Model from JSON
The ultimate time-saver! Paste a URL query string (?id=1&name=test) and get a structured Dart model.
🛠️ Usage
- Summon the command: Press
Ctrl+Shift+P (or Cmd+Shift+P on Mac).
- Search: Type
Generate Dart Model from JSON/Query Params.
- Choose your weapon:
- 📥 Post Model from JSON → Paste JSON → Enter Class Name.
- 📡 Response Model from JSON → Paste JSON → Select Single/List.
- 🔎 Query Params to Post Model from JSON → Paste query string.
- Save & Relax: Choose your save location, and let the
.dart file open automatically!
📸 Process Overview
| Feature |
Visualization |
| Post Model from JSON |
 |
| Response Model (Single) |
 |
| Response Model (List) |
 |
| Query Params to Model |
 |
📜 Model Patterns
🔹 Post Model from JSON
class MyModel extends Equatable {
final String? name;
const MyModel({this.name});
MyModel copyWith({String? name}) => ...
Map<String, dynamic> toMap() => ... // removeWhere null logic
factory MyModel.fromMap(Map<String, dynamic> map) => ...
String toJson() => json.encode(toMap());
}
🔸 Response Model from JSON (Single)
Handles API responses with a wrapper class and recursive nested object parsing.
class MyResponseModel extends Equatable {
final String? message;
final MyData? data;
factory MyResponseModel.fromMap(Map<String, dynamic> map) => ...
factory MyResponseModel.fromJson(dynamic json) => ...
}
📑 Response Model from JSON (List)
Optimized for paginated results where data is a list of items. Includes a wrapper for metadata and a List of typed Data items.
class MyResponseModel {
final String message;
final List<MyData> data;
factory MyResponseModel.fromJson(Map<String, dynamic> json) => ...
}
🔍 Query Params to Post Model from JSON
Convert URL query strings directly into structured Dart models. Great for search and filter objects! Includes Smart Type Inference for int, bool, and double.
Input: search=dart&limit=10&is_active=true
Resulting Pattern:
class SearchFilter extends Equatable {
final String? search;
final int? limit; // Automatically inferred as int
final bool? isActive; // Automatically inferred as bool
const SearchFilter({this.search, this.limit, this.isActive});
Map<String, dynamic> toMap() {
final data = <String, dynamic>{
'search': search,
'limit': limit,
'is_active': isActive,
};
data.removeWhere((key, value) => value == null);
return data;
}
// Includes robust fromMap with type-safe int.tryParse and bool casting
...
}
📦 Installation
- Open VS Code.
- Go to Extensions (
Ctrl+Shift+X).
- Search for
JSON to Dart Model Generator.
- Click Install.
Or install via VSIX: Extensions > ... > Install from VSIX...
⚙️ Requirements
- VS Code
v1.100.0+
- Dart SDK (Recommended)
- Equatable package (Optional, but used in generated code)
Made with ❤️ for the Flutter Community