Skip to content
| Marketplace
Sign in
Visual Studio Code>Formatters>Mock Data GeneratorNew to Visual Studio Code? Get it now.
Mock Data Generator

Mock Data Generator

BuddieKodex

|
83 installs
| (1) | Free
Generate mock data based on model definitions in your project
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Mock Data Generator for VS Code

Generate high-quality mock data for your models directly in Visual Studio Code. This extension analyzes your TypeScript, JavaScript, Prisma, Mongoose, and TypeORM models to create realistic data for development and testing.

Mock Data Generator Demo

Features

  • 🔍 Automatic Model Detection: Analyzes your codebase to find models
  • 🔄 Relationship Analysis: Maintains referential integrity between related models
  • 🌐 Contextual Data: Generates field values based on names and types
  • 📊 Multiple Formats: Output as JSON, SQL, CSV, GraphQL, TypeScript, and more
  • 💾 Database Population: Directly populate MySQL, PostgreSQL, SQLite, MongoDB, and other databases
  • 📝 Smart Constraints: Field constraints from comments and decorators
  • 🌍 Localization: Region-specific data generation
  • 📈 Visualization: Interactive model diagrams
  • 🔧 Customizable: Extensive configuration options

Installation

  1. Open VS Code
  2. Go to Extensions (Ctrl+Shift+X or Cmd+Shift+X)
  3. Search for "Mock Data Generator"
  4. Click Install
  5. Reload VS Code

Quick Start

  1. Open your project folder in VS Code
  2. Open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P)
  3. Type "Mock Data Generator: Generate Mock Data"
  4. Enter the number of records to generate
  5. Select the output format
  6. Done! The generated data will open in a new editor tab

Supported Models

The extension automatically detects models from:

Model Type File Extensions Notes
TypeScript Interfaces .ts, .tsx With or without decorators
TypeScript Classes .ts, .tsx With or without decorators
JavaScript Classes .js, .jsx With JSDoc annotations
Prisma Schema .prisma All Prisma models
Mongoose Schema .js, .ts mongoose.Schema definitions
TypeORM Entities .ts @Entity decorated classes
Sequelize Models .js, .ts sequelize.define or Model.init

Output Formats

Format Description
JSON Structured JSON data
SQL Database INSERT statements
CSV Comma-separated values
GraphQL Queries and mutations
TypeScript Interface declarations with data
API Mock REST API response format
Excel XLSX spreadsheet
Database Direct database population

Database Support

Database Connection Type Features
MySQL Native driver, Docker Table creation, data population
PostgreSQL Native driver, Docker Schema support, JSON types
SQLite Native driver File-based, in-memory
MongoDB Native driver, Docker, Atlas Collection creation, documents
SQL Server Native driver, Docker Table creation, data population
Oracle Native driver Table creation, data population

Database Connection Methods

The extension supports multiple ways to connect to databases:

Local Connections

Connect to databases running on your local machine or network:

  1. Select the database type
  2. Enter connection details (host, port, credentials)
  3. The extension will test the connection before proceeding

Docker Integration

The extension can create and manage Docker containers for databases:

  1. Run Mock Data Generator: Create Database Container
  2. Select the database type (MongoDB, MySQL, PostgreSQL)
  3. Configure container settings
  4. The extension will create a container and provide connection details

You can also generate a Docker Compose file with Mock Data Generator: Generate Docker Compose File.

Cloud Database Connections

Connect to hosted database services:

MongoDB Atlas

For MongoDB Atlas connections, you can use the connection string directly:

  1. Select MongoDB as the database type
  2. Choose "Connection String" as the connection method
  3. Paste your MongoDB Atlas URI (mongodb+srv://username:password@cluster.mongodb.net/...)

No additional details are required when using a connection string.

Other Cloud Providers

For other cloud database providers:

  1. Select the database type
  2. Enter the host address provided by your cloud service
  3. Enter port, credentials, and other required information

Connection Security

  • All database credentials are used only for the current session
  • SSL/TLS connections are supported for all database types
  • Connection strings with embedded credentials are masked in the UI

For more detailed information about database connections, see database-connections.md and docker-setup.md.

Example

Given a simple TypeScript interface:

interface User {
  id: number;
  firstName: string;
  lastName: string;
  email: string;
  age: number;
  isActive: boolean;
  createdAt: Date;
  profile: {
    bio: string;
    avatarUrl: string;
  };
}

The extension will generate realistic data:

{
  "User": [
    {
      "id": 1,
      "firstName": "John",
      "lastName": "Smith",
      "email": "john.smith@example.com",
      "age": 32,
      "isActive": true,
      "createdAt": "2023-08-15T14:30:45Z",
      "profile": {
        "bio": "Full-stack developer with 8 years of experience",
        "avatarUrl": "https://example.com/avatars/johnsmith.jpg"
      }
    }
    // More records...
  ]
}

Extension Settings

This extension contributes the following settings:

  • mockDataGenerator.recordsPerModel: Default number of records to generate per model
  • mockDataGenerator.seed: Random seed for reproducible generation
  • mockDataGenerator.modelFilePatterns: Glob patterns for model files
  • mockDataGenerator.excludePatterns: Glob patterns for files to exclude
  • mockDataGenerator.excludedModels: Models to exclude from generation
  • mockDataGenerator.excludedFields: Fields to exclude from generation
  • mockDataGenerator.useContextualData: Enable field name-based contextual data
  • mockDataGenerator.localization.enabled: Enable locale-specific data generation
  • mockDataGenerator.localization.locale: Default locale for data generation
  • mockDataGenerator.logLevel: Controls logging verbosity

Commands

Command Description
mockDataGenerator.generateMockData Generate mock data from models
mockDataGenerator.visualizeModels Create visualization of models and relationships
mockDataGenerator.configureExtension Open settings for the extension
mockDataGenerator.checkDocker Check if Docker is available on your system
mockDataGenerator.createDatabaseContainer Create a Docker container for database testing
mockDataGenerator.generateDockerCompose Generate a Docker Compose file for databases

Production Readiness

The Mock Data Generator extension is built with production-grade quality and reliability in mind:

Testing and Quality Assurance

  • Comprehensive Test Coverage: Extensive unit and integration tests for all core functionality
  • TypeScript Type Safety: Full TypeScript implementation with strict type checking
  • Error Handling: Robust error handling with detailed logging and user-friendly error messages
  • Continuous Integration: Automated testing via GitHub Actions for every pull request and push

Performance and Scalability

  • Optimized Generation: Efficient algorithms for generating data even for complex model structures
  • Memory Management: Careful memory handling to minimize memory footprint
  • Batch Processing: Support for generating large datasets through batch processing
  • Caching: Strategic caching to improve performance for repeated operations

Reliability and Error Recovery

  • Graceful Degradation: Falls back to simpler generation strategies when advanced features are unavailable
  • Defensive Programming: Extensive input validation and defensive coding practices
  • Detailed Logging: Configurable logging levels for troubleshooting and debugging
  • Recovery Mechanisms: Automatic recovery from common error conditions

Security

  • Secure By Default: No network calls for standard operations
  • Database Connection Security: Support for secure database connections with credential management
  • No Telemetry: Does not collect or transmit any user data
  • Input Validation: Thorough validation of all inputs to prevent injection attacks

Documentation and Support

  • Comprehensive Documentation: Detailed user guide, API documentation, and examples
  • Interactive Examples: Visual examples and tutorials for common use cases
  • Regular Updates: Ongoing maintenance and feature improvements
  • Community Support: Active issue tracking and community engagement

Documentation

For detailed usage and advanced features, see the USAGE.md file.

Changelog

See the CHANGELOG.md for details about each release.

Contributing

We welcome contributions to the Mock Data Generator extension!

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for your changes
  5. Make sure all tests pass with npm test
  6. Submit a pull request

See CONTRIBUTING.md for more details.

License

This extension is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Built with TypeScript
  • Uses Faker.js for data generation
  • Database connectors powered by popular Node.js drivers

Privacy and Telemetry

The Mock Data Generator extension does not collect any personal data or telemetry.

Support

If you encounter any issues or have questions, please create an issue on the GitHub repository.

Recent Improvements

Database Verification

  • Added database record count verification to ensure data is actually inserted
  • Enhanced error reporting for database operations with specific error cases
  • Improved the success message to confirm data insertion with verification
  • Fixed issue where success message could be shown even when data wasn't inserted

MongoDB Improvements

  • Added explicit MongoDB collection creation to handle empty/new databases
  • Fixed issue where tables were skipped instead of created for new databases
  • Implemented template document approach to establish collection structure
  • Improved column detection for empty collections to allow data population
  • Enhanced error logging with more detailed diagnostics
  • Fixed issue where empty error objects were incorrectly reported after successful operations

Enjoy generating mock data!

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