Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>JSON to Dart Model GeneratorNew to Visual Studio Code? Get it now.
JSON to Dart Model Generator

JSON to Dart Model Generator

Raian Ruku

|
2 installs
| (0) | Free
Generate Dart model classes from JSON — supports Post, Single Response, and List Response patterns.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

🚀 JSON to Dart Model Generator

Dart JSON Version


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

  1. Summon the command: Press Ctrl+Shift+P (or Cmd+Shift+P on Mac).
  2. Search: Type Generate Dart Model from JSON/Query Params.
  3. 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.
  4. Save & Relax: Choose your save location, and let the .dart file open automatically!

📸 Process Overview

Feature Visualization
Post Model from JSON Post Model
Response Model (Single) Single Model
Response Model (List) List Model
Query Params to Model Query 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

  1. Open VS Code.
  2. Go to Extensions (Ctrl+Shift+X).
  3. Search for JSON to Dart Model Generator.
  4. 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

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft