typicode /json-server

Get a full fake REST API with zero coding in less than 30 seconds (seriously)

★ 75,732⑂ 7,282
JavaScriptCreated 2013-11-27
75,732
stars
+-2+-2+9
7,282
forks
–
watchers
–
prs
–
issues
–
releases
–
discussions

README

JSON-Server



 [!IMPORTANT]
 Viewing beta v1 documentation – usable but expect breaking changes. For stable version, see here

 [!NOTE]
 Using React ⚛️ and tired of CSS-in-JS? See 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.



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

|                                                                                                                                                                                |                                                                                                                                                                              |
| :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------

Snapshot: 2026-11-10T09:35:25Z · Data license Apache-2.0 · JSON