https://github.com/typicode/json-server
Get a full fake REST API with zero coding in less than 30 seconds (seriously)
https://github.com/typicode/json-server
api fake frontend json mock rest test
Last synced: 1 day ago
JSON representation
Get a full fake REST API with zero coding in less than 30 seconds (seriously)
- Host: GitHub
- URL: https://github.com/typicode/json-server
- Owner: typicode
- License: mit
- Created: 2013-11-27T13:21:13.000Z (almost 13 years ago)
- Default Branch: main
- Last Pushed: 2026-03-23T19:40:00.000Z (8 months ago)
- Last Synced: 2026-11-16T07:16:57.678Z (4 days ago)
- Topics: api, fake, frontend, json, mock, rest, test
- Language: JavaScript
- Homepage:
- Size: 4.06 MB
- Stars: 75,745
- Watchers: 975
- Forks: 7,276
- Open Issues: 721
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- apis-tools-development - Json-Server
- awesome-javascript - typicode/json-server - Get a full fake REST API with zero coding in less than 30 seconds (seriously) (Other)
- awesome-api-devtools - Json-Server - Full fake REST API with zero coding. (API Debugging and Mocking / Desktop)
- awesome-frontend - json-server
- awesome-sdet-collection - json-server - Full fake REST API with zero coding. (Test Data & Mocking / .NET)
- awesome-api - json-server
- awesome-nodejs - json-server - Get a full fake REST API with zero coding in less than 30 seconds.  (Repository / HTTP)
- awesome-list - typicode/json-server - Get a full fake REST API with zero coding in less than 30 seconds (seriously) (JavaScript)
- awesome-json - JSON Server - Get a full fake REST API with zero coding in less than 30 seconds. (Databases)
- awesome-rest - json-server - Serve a REST API from fixture files using quick prototyping. (Testing / Mocking)
- awesome-rest - json-server - Serve a REST API from fixture files using quick prototyping. (Testing / Mocking)
- awesome-tools - **json-server** - 最佳 RESTful API Mock (在線使用)
- awesome-web-development - :+1:**json-server** Mock Get a full fake REST API with zero coding in less than 30 seconds (seriously)
- awesome-starred - typicode/json-server - Get a full fake REST API with zero coding in less than 30 seconds (seriously) (others)
- awesome-github-star - json-server
- tech-resources - JSON Server
- awesome-nodejs - json-server - 在不到 30 秒的时间内获得具有零编码的完整伪造的 REST API。  (GIT 仓库 / HTTP)
- awesome - json-server - Get a full fake REST API with zero coding in less than 30 seconds (seriously) (Test tools)
- awesome_frontend_development_resources - json-server - Get a full fake REST API with zero coding in less than 30 seconds (seriously). (Tools / React Components)
- awesome-api - json-server
- awesome - json-server
- awesome-api-documentation-tools - JSON Server - Fake REST API server with documentation features. (Mock Servers)
- awesome-nodejs-projects - JSON-server - Get a full fake REST API with zero coding in less than 30 seconds (seriously). (Developers)
- awesome-bunx - json-server - server` | 1.0.0-beta.15<br>2026-03-23 | (API & HTTP Tools)
- awesome - json-server - Get a full fake REST API with zero coding in less than 30 seconds (seriously). (Tools / React Components)
- awesome-side-quests - typicode/json-server
- awesome-ops - typicode/json-server - 11-27|2025-10-29 | 一款能够直接将 json 内容转成 REST API 接口的工具,你可以在日常开发中,通过该工具快速进行调试 | (命令行工具)
- my-awesome - typicode/json-server - 03 star:75.7k fork:7.3k Get a full fake REST API with zero coding in less than 30 seconds (seriously) (JavaScript)
- awesome-stuff - GitHub - typicode/json-server: Get a full fake REST API with zero coding in less than 30 seconds (seriously)
- APIs-tools-collection - Json-Server - Full fake REST API with zero coding. (API Debugging and Mocking / Desktop)
- awesome-list - json-server
- awesome-frontend - JSON Server - 模拟 API (2. 调试工具)
- awesome-github-projects - json-server - Get a full fake REST API with zero coding in less than 30 seconds (seriously) ⭐75,748 `JavaScript` (⚙️ Backend & APIs)
- -awesome-nodejs-projects - JSON-server - Get a full fake REST API with zero coding in less than 30 seconds (seriously). (Developers)
- awesome-nodejs-projects - JSON-server - Get a full fake REST API with zero coding in less than 30 seconds (seriously). (Developers)
- awesome-nodejs-projects - JSON-server - Get a full fake REST API with zero coding in less than 30 seconds (seriously). (Developers)
- my-awesome-starred - json-server - Get a full fake REST API with zero coding in less than 30 seconds (seriously) (JavaScript)
- jimsghstars - typicode/json-server - Get a full fake REST API with zero coding in less than 30 seconds (seriously) (JavaScript)
- awesome - json-server - Get a full fake REST API with zero coding in less than 30 seconds (seriously) (JavaScript)
- awesome-rest-api - Json-Server
- stars - json-server
- awesome-tools - Json-server - A cool way to set up a local mock json api for use to mock a real API. `Free` `OSS` (CLI Applications)
- github-ultimate-repos - typicode/json-server - | ⭐ 75,739★ | 🍴 7,262 | 💻 `JavaScript`🔗 <https://github.com/typicode/json-server>📝 Get a full fake REST API with zero coding in less than 30 seconds (seriously)⚙️ `HTTP request stream decoding -> middleware execution pipeline -> routing table pattern match -> asynchronous controller handler -> serialized JSON response dispatch.` (📜 Master Categorized Repository Directory (100% Clickable Links) / [53] BACKEND WEB FRAMEWORKS, MICROSERVICES, REST / GRAPHQL / GRPC APIS & ORMS)
- awesome-api-management-tools - Json-Server - Full fake REST API with zero coding. (API Debugging and Mocking / Desktop)
- awesome - typicode/json-server
- awesome-bookmarks - JSON-server - 可以配合 LowDB 使用 快速搭建一个 REST API (前端常用)
- awesome-libraries - JSON Server, Get a full fake REST API with zero coding in less than 30 seconds
- awesome-javascript-libraries - typicode/json-server - Get a full fake REST API with zero coding in less than 30 seconds (seriously) (Uncategorized / Uncategorized)
- awesome-front-end - JSON Server - 模拟 API (2. 调试工具)
- awesome-nodejs - json-server - 指定 json 文件作为 api 的数据源,模拟服务端接口数据 (Uncategorized / Uncategorized)
- awesome-frontend-libraries - json-server
README
# JSON-Server
[](https://github.com/typicode/json-server/actions/workflows/node.js.yml)
> [!IMPORTANT]
> Viewing beta v1 documentation – usable but expect breaking changes. For stable version, see [here](https://github.com/typicode/json-server/tree/v0.17.4)
> [!NOTE]
> Using React ⚛️ and tired of CSS-in-JS? See [MistCSS](https://github.com/typicode/mistcss) 👀
## Install
```shell
npm install json-server
```
## Usage
Create a `db.json` or `db.json5` file
```json
{
"$schema": "./node_modules/json-server/schema.json",
"posts": [
{ "id": "1", "title": "a title", "views": 100 },
{ "id": "2", "title": "another title", "views": 200 }
],
"comments": [
{ "id": "1", "text": "a comment about post 1", "postId": "1" },
{ "id": "2", "text": "another comment about post 1", "postId": "1" }
],
"profile": {
"name": "typicode"
}
}
```
View db.json5 example
```json5
{
posts: [
{ id: "1", title: "a title", views: 100 },
{ id: "2", title: "another title", views: 200 },
],
comments: [
{ id: "1", text: "a comment about post 1", postId: "1" },
{ id: "2", text: "another comment about post 1", postId: "1" },
],
profile: {
name: "typicode",
},
}
```
You can read more about JSON5 format [here](https://github.com/json5/json5).
Start JSON Server
```bash
npx json-server db.json
```
This starts the server at `http://localhost:3000`. You should see:
```
JSON Server started on PORT :3000
http://localhost:3000
```
Access your REST API:
```bash
curl http://localhost:3000/posts/1
```
**Response:**
```json
{
"id": "1",
"title": "a title",
"views": 100
}
```
Run `json-server --help` for a list of options
## Sponsors ✨
### Gold
| |
| :--------------------------------------------------------------------------------------------------------------------------------------------------------: |
|
|
|
|
|
|
|
|
| 
### Silver
| |
| :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|
|
### Bronze
| | |
| :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|
|
|
[Become a sponsor and have your company logo here](https://github.com/users/typicode/sponsorship)
## Query Capabilities
JSON Server supports advanced querying out of the box:
```http
GET /posts?views:gt=100 # Filter by condition
GET /posts?_sort=-views # Sort by field (descending)
GET /posts?_page=1&_per_page=10 # Pagination
GET /posts?_embed=comments # Include relations
GET /posts?_where={"or":[...]} # Complex queries
```
See detailed documentation below for each feature.
## Routes
### Array Resources
For array resources like `posts` and `comments`:
```http
GET /posts
GET /posts/:id
POST /posts
PUT /posts/:id
PATCH /posts/:id
DELETE /posts/:id
```
### Object Resources
For singular object resources like `profile`:
```http
GET /profile
PUT /profile
PATCH /profile
```
## Query params
### Conditions
Use `field:operator=value`.
Operators:
- no operator -> `eq` (equal)
- `lt` less than, `lte` less than or equal
- `gt` greater than, `gte` greater than or equal
- `eq` equal, `ne` not equal
- `in` included in comma-separated list
- `contains` string contains (case-insensitive)
- `startsWith` string starts with (case-insensitive)
- `endsWith` string ends with (case-insensitive)
Examples:
```http
GET /posts?views:gt=100
GET /posts?title:eq=Hello
GET /posts?id:in=1,2,3
GET /posts?author.name:eq=typicode
GET /posts?title:contains=hello
GET /posts?title:startsWith=Hello
GET /posts?title:endsWith=world
```
### Sort
```http
GET /posts?_sort=title
GET /posts?_sort=-views
GET /posts?_sort=author.name,-views
```
### Pagination
```http
GET /posts?_page=1&_per_page=25
```
**Response:**
```json
{
"first": 1,
"prev": null,
"next": 2,
"last": 4,
"pages": 4,
"items": 100,
"data": [
{ "id": "1", "title": "...", "views": 100 },
{ "id": "2", "title": "...", "views": 200 }
]
}
```
**Notes:**
- `_per_page` defaults to `10` if not specified
- Invalid `_page` or `_per_page` values are automatically normalized to valid ranges
### Embed
```http
GET /posts?_embed=comments
GET /comments?_embed=post
```
### Complex filter with `_where`
`_where` accepts a JSON object and overrides normal query params when valid.
```http
GET /posts?_where={"or":[{"views":{"gt":100}},{"author":{"name":{"lt":"m"}}}]}
```
## Delete dependents
```http
DELETE /posts/1?_dependent=comments
```
## Static Files
JSON Server automatically serves files from the `./public` directory.
To serve additional static directories:
```bash
json-server db.json -s ./static
json-server db.json -s ./static -s ./node_modules
```
Static files are served with standard MIME types and can include HTML, CSS, JavaScript, images, and other assets.
## Migration Notes (v0 → v1)
If you are upgrading from json-server v0.x, note these behavioral changes:
- **ID handling:** `id` is always a string and will be auto-generated if not provided
- **Pagination:** Use `_per_page` with `_page` instead of the deprecated `_limit` parameter
- **Relationships:** Use `_embed` instead of `_expand` for including related resources
- **Request delays:** Use browser DevTools (Network tab > throttling) instead of the removed `--delay` CLI option
> **New to json-server?** These notes are for users migrating from v0. If this is your first time using json-server, you can ignore this section.