Generate mock APIs instantly from JSON. No backend code needed.
Mirage is a lightweight CLI tool that turns a simple JSON file into a fully functional HTTP API server. Perfect for frontend development, testing, prototyping, and demos.
Create mirage.json:
{
"endpoints": [
{
"method": "GET",
"path": "/api/users",
"response": {"users": [{"id": 1, "name": "Alice"}]}
},
{
"method": "GET",
"path": "/api/users/{id}",
"response": {"id": "{id}", "name": "Alice"}
}
]
}Run mirage serve. Call GET /api/users/32 → the response will have "id": 32. Any {varName} in the response is replaced by the URL value.
Your API is now live on http://localhost:8080 !
# Build
go build -o mirage main.go
# Start with your config
mirage serve whatever-you-want.json
# Or use the built-in example
mirage serve --example
# Custom port
mirage serve --port=3000
# Multiple ports (one server instance per port, one log file per port)
mirage serve --ports=8080,8081,8082 mirage.json- Path variables -
/users/{id}matches any ID; put"{id}"in the response and it’s replaced by the URL value (numbers/decimals typed correctly) - Custom status codes - Return 201, 404, 500, etc.
- Response delays - Simulate slow networks
- Built-in health check -
/healthendpoint always available - Request logging - one log file per port:
mirage-logs-{port}-{timestamp}.txt(e.g.mirage-logs-8080-20060102-150405.txt). One line per request.GET /logsreturns logs for the port that served the request (JSON) - Auto-config detection - Just run
mirage serveifmirage.jsonexists
For complete documentation, examples, and advanced features:
mirage guide-en # Generate English guide
mirage guide-fr # Generate French guideThis creates mirage-guide-en.md or mirage-guide-fr.md with everything you need to know about Mirage.
Made with ❤️ by Myself