MockM - The Ultimate API Development Companion π
July 25, 2025 Β· View on GitHub
One-stop API mocking and debugging platform for seamless frontend-backend parallel development
δΈζ | English | π Documentation
β¨ Core Features
π― Zero Configuration - Get started with 2 commands, instant API server
π Smart Proxy - Non-invasive CORS solution, goodbye to CORS headaches
π Data Generation - Built-in MockJS for realistic data generation
π Restful API - Auto-generated CRUD endpoints, doubled development efficiency
πΈοΈ WebSocket Support - Complete real-time communication solution
π± Visual Management - Intuitive Web UI with drag-and-drop API management
π Request Replay - One-click replay of historical requests
π Remote Debugging - Built-in tunneling for anywhere collaboration
β‘ Hot Reload - Real-time configuration updates, smooth development experience
π Quick Start
Get Started in 1 Minute
# Global installation
npm i -g mockm
# Start with examples
mm --config
π That's it! You now have:
- β CORS-enabled proxy server (http://127.0.0.1:9000)
- β Visual management interface (http://127.0.0.1:9005)
- β Complete API ecosystem
- β Request recording and replay functionality
Experience Immediately
- π Visit http://127.0.0.1:9000/api/1 to see API in action
- π Visit http://127.0.0.1:9005/#/get/api/1 to view request details
- π§ Check the generated config file to explore more features
π‘ Tip: The
--configparameter creates an example configuration with common feature demonstrations
π‘ Core Features Showcase
π CORS Proxy - Solve All CORS Issues with One Line
Problem: Always frustrated by CORS errors in frontend development?
Solution: MockM eliminates CORS headaches forever!
# Simplest CORS proxy
mm proxy=http://your-backend:8080
Or use a configuration file:
module.exports = {
proxy: 'http://your-backend:8080'
}
Result: Your original http://your-backend:8080/api/users now works through http://127.0.0.1:9000/api/users with automatic CORS handling!
π Instant APIs - Create Complete Endpoints with 3 Lines
module.exports = {
api: {
'/my/awesome/api': {
message: 'My first API',
data: { success: true }
}
}
}
Instantly available: http://127.0.0.1:9000/my/awesome/api
π Restful API Generator - Complete CRUD with One Config
Want a complete blog system? Just do this:
module.exports = {
db: {
posts: [
{ id: 1, title: 'My First Blog', content: 'Using MockM is incredibly simple!' }
]
}
}
Instantly get:
GET /posts- Get all postsGET /posts/1- Get specific postPOST /posts- Create new postPUT /posts/1- Update postDELETE /posts/1- Delete postGET /posts?q=keyword- Search posts
π Smart Data Generation - Deep MockJS Integration
module.exports = util => ({
db: {
users: util.libObj.mockjs.mock({
'data|20-50': [{
'id|+1': 1,
name: '@name', // Random name
email: '@email', // Random email
avatar: '@image("200x200")', // Random avatar
'age|18-65': 1, // Random age 18-65
address: '@county(true)' // Random address
}]
}).data
}
})
π οΈ Response Interception & Modification - No Backend Cooperation Needed
Need to modify backend response data? Easy:
module.exports = {
proxy: {
'/': 'http://your-backend:8080',
'/api/user': ['data.name', 'John Doe'], // Change username to John Doe
'/api/status': ['success'] // Return "success" directly
}
}
β±οΈ API Delay Simulation - Test Slow Network Conditions
module.exports = {
proxy: {
'/api/slow': {
mid(req, res, next) {
setTimeout(next, 3000) // 3-second delay
}
}
}
}
π WebSocket Support - Real-time Communication Made Easy
module.exports = {
api: {
'ws /chat'(ws, req) {
ws.send('Welcome to the chat room!')
ws.on('message', msg => {
ws.send(`Echo: ${msg}`)
})
}
}
}
π± Visual Management - Drag-and-Drop API Management
Easily manage APIs through Web UI:
- π View all API endpoints
- π Search and filter APIs
- βοΈ Edit API logic online
- π View request history and statistics
- π One-click replay historical requests
π Remote Collaboration - One-click Tunneling
module.exports = {
remote: true // Enable remote access
}
Auto-generate public URLs supporting:
- π Remote team collaboration
- π± WeChat mini-program development
- π Third-party service integration
π Use Cases
π¨βπ» Frontend Developers
- Quick Setup Mock services without waiting for backend
- CORS Solution One line of code solves all CORS issues
- Data-Driven Develop with realistic data
π©βπ» Backend Developers
- API Documentation Auto-generated docs for smoother frontend integration
- Request Parameters One-click sharing, no more screenshot parameters
- Debug Tools Complete request history tracking
π― QA Engineers
- API Testing Built-in Postman-like tools
- Data Simulation Easy testing of edge cases
- Performance Testing Delay and error simulation
π₯ Team Collaboration
- Remote Debugging One-click public URL generation
- Version Control Git-friendly configuration files
- Environment Isolation Flexible multi-environment configs
πΈ Interface Preview
π±οΈ Click to view more interface screenshots
Request Record Details

API Request History

Visual API Editor

π Feature Comparison
π Comprehensive Feature Matrix
| Feature | MockM | MockJS | JSON-Server | YApi/Rap2 | Postman Mock | Wiremock | MSW | Faker.js | Apifox |
|---|---|---|---|---|---|---|---|---|---|
| π Zero Config | β | β | β | β | β | β | β | β | β |
| π CORS Handling | β Auto | β | β | β | β | β | β | β | β |
| π Data Generation | β Built-in MockJS | β | β | β | πΆ Basic | πΆ Basic | β | β | β |
| π Restful API | β Auto-generated | β | β | β | β | β | β | β | β |
| πΈοΈ WebSocket | β | β | β | β | β | β | β | β | β |
| π± Visual Management | β | β | β | β | β | πΆ 3rd party | β | β | β |
| π Request Replay | β | β | β | β | β | β | β | β | β |
| π Remote Debugging | β Built-in tunneling | β | β | β | β Cloud | β | β | β | β Cloud |
| β‘ Hot Reload | β | β | β | β | β | β | β | β | β |
| π οΈ Response Interception | β | β Frontend only | β | β | β | β | β | β | β |
| π» Runtime | Node.js | Browser | Node.js | Java/Docker | Cloud | Java | Browser/Node | Node.js | Desktop/Cloud |
| π° Cost | Free | Free | Free | Free/Paid | Free/Paid | Free | Free | Free | Free/Paid |
π― Tool Positioning
Data Generation Tools
- MockJS: Frontend-only data mocking, no real network requests visible
- Faker.js: Data generation library only, requires building your own server
- MockM: Built-in MockJS + complete server, ready to use
API Server Tools
- JSON-Server: Simple REST API generation, no data generation or CORS features
- WireMock: Powerful Java ecosystem mock server, complex configuration
- MockM: Express ecosystem, simple configuration, comprehensive features
Testing Tools
- Postman Mock: Cloud-based mock service, requires internet, relatively basic features
- MSW: Focused on test environment request interception, steep learning curve
- MockM: Development + testing dual-purpose, local-first, cloud-expandable
Platform Tools
- YApi/Rap2: Enterprise API management platform, complex deployment
- Apifox: Commercial all-in-one API tool, powerful but paid features
- MockM: Lightweight local tool, focused on development efficiency
π‘ Selection Guide
| Use Case | Recommended Tool | Reason |
|---|---|---|
| π Rapid Prototyping | MockM | Zero config, instant start |
| π§ͺ Frontend Unit Testing | MSW + Faker.js | Professional testing toolchain |
| π’ Enterprise API Management | YApi + MockM | Documentation + development debugging |
| βοΈ Team Collaboration | Apifox / MockM Remote | Cloud collaboration |
| π― Java Backend Testing | WireMock | Java ecosystem integration |
| π Pure Data Generation | MockJS / Faker.js | Lightweight solution |
β Common Misconceptions Clarified
π€ "What's the difference between MockM and MockJS?"
- MockJS: Only intercepts XHR requests in browser, no real network requests
- MockM: Runs a real server, visible in Network panel, supports CORS
π€ "Isn't MockM the same as JSON-Server?"
- JSON-Server: Only generates simple REST APIs, no data generation capabilities
- MockM: REST API + Data Generation + Proxy + Visual Management + Remote Debugging
π€ "Why not just use Postman Mock?"
- Postman Mock: Cloud service, requires internet, relatively basic features, complex setup
- MockM: Local-first, comprehensive features, zero-config start, optional cloud mode
π€ "MSW looks powerful too?"
- MSW: Focused on testing environments, mainly for unit and integration tests
- MockM: Focused on development environments, provides complete dev server solution
π€ "We already have YApi/Apifox, do we still need MockM?"
- YApi/Apifox: Heavy on documentation and team collaboration, still need local tools for development
- MockM: Perfect complement, focused on development efficiency, works great with documentation platforms
π€ Community & Support
π Documentation & Tutorials
π Related Projects
| Project | Description |
|---|---|
| π¨ Taroify | Taro version of mobile component library Vant, accelerating mini-program development |
| π― wot-design-uni | Vue3+TS uni-app component library with 70+ high-quality components |
If you have a project that needs to be showcased on this page, please let me know.
π¬ Communication & Feedback
π License
This project is licensed under MIT
Copyright (c) 2017-present, xw
β If this project helps you, please give us a Star!