
json-server
A fake REST API server built from a JSON file, for prototyping and testing front ends.
- Stars
- 75.7k
- Forks
- 7.3k
- Licence
- MIT
- Language
- JavaScript
- Last update
- 8 months ago
- Type
- Dev tool
What it is
json-server is a Node.js tool that turns a JSON file (db.json or db.json5) into a working REST API with routes for each top-level key. It lets front-end developers build and test against realistic endpoints before the real backend exists. The README shows it supports filtering, sorting, pagination, and relations through query parameters.
- Run npx json-server db.json to get a local API at localhost:3000 in seconds
- Filter posts with queries such as /posts?views:gt=100
- Page through results with _page and _per_page
- Embed related records, for example /posts?_embed=comments
- Serve static front-end files alongside the API using the -s option
Great for
- Front-end developers who need a backend stub while the real API is not ready
- Developers writing demos or prototypes that need data that persists during a session
- Students learning how REST routes and query parameters behave
- Teams that want a quick mock API for local testing
Not ideal for
- Production systems, since the README presents it as a development and mocking tool and does not describe production use
- Projects that need a real database or authentication, which the README does not mention
- Users who need the stable v0 behavior, because the README says the v1 beta documentation is shown and may have breaking changes
How to get it
- 1
Install with a package manager
You'll need: Node.js (version not specified in the README) · npm
Install the package
npm install json-server - 2
Run it
- Create a db.json file with some top-level arrays or objects, such as posts and comments
- Run npx json-server db.json
- Open http://localhost:3000 or run curl http://localhost:3000/posts/1 to see a response
- 3
Get the most out of it
- Use db.json5 if you want comments and trailing commas in your data file
- Add a $schema line in db.json pointing to node_modules/json-server/schema.json
- Use -s to serve extra static directories alongside the API
- Use _where for complex filters and _embed or _dependent for relations
- Run json-server --help to see the full list of options
Downloads
Strengths
- Very fast setup from a single JSON file, with no server code to write
- Supports common query features like filtering, sorting, pagination and embedding out of the box
- Widely used, with about 75k GitHub stars and an MIT license
Trade-offs
- The README marks the v1 beta as usable but subject to breaking changes
- Latest release is a beta (v1.0.0-beta.15), so the stable path is v0.17.4 per the README
- Not designed for production use, and the README does not describe any security features
How it compares
| Project | Stars | Type | Level | Updated | Best for |
|---|---|---|---|---|---|
| json-server (this) | 75.7k | Dev tool | beginner | 8 months ago | Front-end developers who need a backend stub while the real API is not ready |
| FlareSolverr | 16.1k | App | intermediate | 12 days ago | Developers whose scripts are blocked by Cloudflare challenges on pages they are allowed to access |
| fastapi | 105k | Library | beginner | 4 days ago | Python developers building JSON APIs or back-end services |
| quivr | 39.6k | Framework | advanced | 4 days ago | Developers building a search or monitoring pipeline over a stream of documents |
| postgrest | 27.7k | App | intermediate | 6 days ago | Developers who already have a PostgreSQL database and want an HTTP API on top of it quickly |
| msw | 18.3k | Library | intermediate | 20 days ago | Frontend developers who need to work before a backend API is ready |
Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.