Instantly generate a fake API server from your Prisma or database schema. Develop faster with realistic mock APIs — no backend required.
SchemaGhost is a developer tool that reads your Prisma or database schema and instantly spins up a fully mocked REST API server.
No need to build a backend or write mocks by hand — SchemaGhost understands your data models and relations, serving realistic fake data out of the box.
- Schema-aware → Parses Prisma schemas, understands models, fields, and relations.
- Auto API generation → RESTful endpoints for all models generated dynamically.
- Realistic mock data → Uses smart faker logic for each field type.
- Relations & nesting → Handles one-to-many, many-to-many, and nested fetches.
- Configurable → Customize mock data generation rules with simple config files.
- Zero setup → Just point it to your schema and start developing instantly.
- Multiple schema support → Work on monorepos or multiple projects easily.
- Fast & lightweight → Minimal dependencies, perfect for local dev and testing.
npm install -g schemaghostschemaghost --schema ./prisma/schema.prisma --port 8080This will instantly generate REST endpoints for all your models, e.g.:
GET /users
GET /users/:id
POST /users
PUT /users/:id
DELETE /users/:id
All endpoints serve realistic mock data.
You can override default mock data generation with a simple config file (mock-config.js):
module.exports = {
User: {
name: () => `User_${Math.floor(Math.random() * 1000)}`,
email: () => `user${Math.floor(Math.random() * 1000)}@example.com`,
},
};Run SchemaGhost with the config:
schemaghost --schema ./prisma/schema.prisma --mock-config ./mock-config.jsIf you have a Post model with a relation to User, you can fetch nested data:
GET /posts
Response:
[
{
"id": 1,
"title": "My First Post",
"author": {
"id": 1,
"name": "User_42"
}
}
]Work on monorepos or multiple projects:
schemaghost --schema ./apps/api/prisma/schema.prisma
schemaghost --schema ./libs/shared/prisma/schema.prisma| Option | Description | Default |
|---|---|---|
-s, --schema <path> |
Path to your Prisma schema | ./prisma/schema.prisma |
-p, --port <number> |
Port to run the API server | 8080 |
-c, --count <number> |
Number of records per model | 10 |
-o, --output <file> |
Save generated mock data to a file | None |
--mock-config <file> |
Path to custom mock config | None |
Clone the repo and install dependencies:
git clone https://github.com/mockilo/schemaghost.git
cd schemaghost
npm installRun locally:
npm link
schemaghost --schema ./examples/schema.prismaSchemaGhost is licensed under BSL-1.1.