json-server is a lightweight Node.js tool for rapidly creating a full fake REST API from a JSON or JSON5 file, requiring virtually no coding. It is currently in active development with a `v1.0.0-beta.x` series (current: `v1.0.0-beta.15`), and new beta versions are released frequently, sometimes multiple times a week, as features are added and fixes applied. The last stable release is `v0.17.4`. Its primary differentiation lies in its simplicity and speed, making it an ideal choice for frontend development prototyping, mobile app mocking, and quick testing environments where a real backend is not yet available or too complex to set up. It automatically handles typical REST operations (GET, POST, PUT, PATCH, DELETE) and supports advanced features like filtering, sorting, pagination, and relationships based on the structure of the provided data file.
npm install json-serverVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to start JSON Server programmatically with a `db.json` file, applying default middleware, adding a custom route, and listening on port 3000.
Refer to the latest changelog and documentation for `v1.x` updates. For a stable version, consider `v0.17.4`.
Refactor existing queries to use `_where` for advanced filtering and standard `_page`, `_limit` parameters for pagination. For example, use `_page=1&_limit=10` instead of `_start=0&_end=10`.
Do not rely on incremental numeric IDs; treat IDs as opaque strings. When creating new resources (POST), omit the `id` field from the request body or be aware it will be ignored in favor of a server-generated ID.
Use the `.json5` extension for files formatted with JSON5 syntax. For `.json` files, ensure strict JSON validity. `json-server` can automatically insert a `$schema` reference upon startup if missing.
Ensure your request body is valid JSON. Since `v1.0.0-beta.13`, `json-server` returns a `400 Bad Request` error for invalid JSON bodies, providing clearer feedback.
Update `json-server` to `v1.0.0-beta.15` or newer. This version fixes the behavior to return JSON responses for 404 errors, aligning with typical API expectations.
Remove the `id` field from the request body when creating new resources via POST. Rely on the server to generate and return the `id` in the response for the newly created resource.
No dependency data recorded yet.