When building or testing front-end applications, having a lightweight backend for mock data can save a lot of time. That’s where JSON Server comes in. It allows you to set up a fully functional REST API using a simple JSON file, without the need for a real database or backend code.
In this guide, we’ll walk through how to install and run JSON Server on a Windows computer step-by-step.
What You’ll Need
Before you begin, make sure you have the following:
- A Windows 10 or Windows 11 computer
- Node.js and npm (Node Package Manager) installed
- A stable internet connection
- Basic familiarity with the Command Prompt or PowerShell
If you don’t have Node.js installed, download it from the official Node.js website and install the LTS (Long-Term Support) version. The installer includes npm by default.
Step 1: Verify Node.js and npm Installation
Once Node.js is installed, open Command Prompt or PowerShell and run the following commands to verify the installation:
node -v
npm -v
You should see version numbers for both commands. If you don’t, restart your computer and try again.
Step 2: Install JSON Server Globally
You can install JSON Server globally on your system using npm. In your terminal, run:
npm install -g json-server
This command will download and install the latest version of JSON Server and make it available system-wide.
To verify the installation, run:
json-server --version
If it displays a version number, JSON Server has been installed successfully.
Step 3: Create a JSON File for Your Data
Next, you’ll need a data source for your mock API. Create a new folder where you want to store your project files, for example:
mkdir json-server-demo
cd json-server-demo
Inside this folder, create a new file named db.json and add some sample data:
{
"posts": [
{ "id": 1, "title": "Hello World", "author": "John" },
{ "id": 2, "title": "JSON Server Guide", "author": "Ajoy" }
],
"comments": [
{ "id": 1, "body": "Nice post!", "postId": 1 }
]
}
This file acts as your database. JSON Server will read it and create API endpoints automatically.
Step 4: Start JSON Server
Now it’s time to start your local server. Run the following command inside the same folder as your db.json file:
json-server --watch db.json
You’ll see output similar to this:
\{^_^}/ hi!
Loading db.json
Done
Resources
http://localhost:3000/posts
http://localhost:3000/comments
Home
http://localhost:3000
Your fake REST API is now live at http://localhost:3000.
Step 5: Access and Test Your API
Open a browser and navigate to:
http://localhost:3000/posts
You should see the JSON data from your db.json file displayed in the browser.
You can also use tools like Postman, Insomnia, or cURL to send GET, POST, PUT, PATCH, and DELETE requests to your API — just like you would with a real backend.
For example:
GET /postsreturns all posts.POST /postsadds a new post.DELETE /posts/1removes the post with ID 1.
Step 6: Optional – Change the Default Port
By default, JSON Server runs on port 3000. You can change this by using the --port flag:
json-server --watch db.json --port 5000
Your API will now be accessible at http://localhost:5000.
Wrapping Up
JSON Server is one of the easiest and fastest ways to create a mock REST API for testing and front-end development. With just Node.js and a JSON file, you can simulate backend behavior, test endpoints, and integrate your front-end projects — all without setting up an actual database.
Once you’re familiar with it, you can even customize routes, add middleware, or use JSON Server as part of a more advanced development workflow.