# Deployment Options for JSON Server: A Complete Guide to Hosting Your Mock API

> Explore diverse JSON Server deployment options from local machines to cloud platforms like Heroku Vercel Netlify AWS Lambda Google Cloud Run and Azure. Host your mock API easily.

- Repository: [typicode/json-server](https://github.com/typicode/json-server)
- Tags: how-to-guide
- Published: 2026-03-01

---

**JSON Server can be deployed on any platform that supports Node.js, including local development machines, Docker containers, Heroku, Vercel, Netlify, AWS Lambda, Google Cloud Run, and Azure App Service.**

JSON Server by typicode is a zero-configuration REST API generator that creates a full fake API from a JSON file. Because it runs as a standard Node.js application, you have flexible deployment options for JSON Server ranging from local prototyping to production-grade cloud hosting.

## Local Development and Testing

The simplest way to run JSON Server is on your local machine. This requires no configuration files and is ideal for rapid prototyping.

Install the package globally or use `npx` to run it without installation:

```bash
npx json-server --watch db.json

```

Alternatively, install it as a project dependency and add a start script to your [`package.json`](https://github.com/typicode/json-server/blob/main/package.json):

```json
{
  "scripts": {
    "start": "json-server --watch db.json"
  }
}

```

## Containerized Deployment with Docker

For isolated, reproducible environments, deploy JSON Server using Docker. The repository provides a `Dockerfile` example that packages the application into a lightweight container.

Create a `Dockerfile` in your project root:

```dockerfile
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
COPY db.json ./
EXPOSE 3000
CMD ["npx", "json-server", "--watch", "db.json", "--host", "0.0.0.0"]

```

Build and run the container locally:

```bash
docker build -t my-json-server .
docker run -p 3000:3000 my-json-server

```

This approach works on any host supporting Docker, including CI pipelines, cloud VMs, and on-premises servers.

## Platform-as-a-Service Deployment Options

PaaS providers offer the simplest path to production for JSON Server, handling infrastructure management and scaling automatically.

### Deploying JSON Server to Heroku

Heroku requires a `Procfile` to define the web process. You must bind to `0.0.0.0` and use the `$PORT` environment variable provided by the platform.

Create a `Procfile`:

```

web: npx json-server --watch db.json --host 0.0.0.0 --port $PORT

```

Deploy using Git:

```bash
git push heroku main

```

### Deploying JSON Server to Vercel

Vercel deploys serverless functions, requiring you to wrap JSON Server in a function handler.

Create [`api/index.js`](https://github.com/typicode/json-server/blob/main/api/index.js):

```javascript
const jsonServer = require('json-server')
const server = jsonServer.create()
const router = jsonServer.router('db.json')
const middlewares = jsonServer.defaults()

server.use(middlewares)
server.use(router)

module.exports = server

```

Add [`vercel.json`](https://github.com/typicode/json-server/blob/main/vercel.json) to route requests:

```json
{
  "functions": {
    "api/index.js": {
      "runtime": "nodejs20.x"
    }
  },
  "routes": [{ "src": "/(.*)", "dest": "/api/index.js" }]
}

```

Deploy with the Vercel CLI:

```bash
vercel --prod

```

### Deploying JSON Server to Netlify

Netlify Functions provide another serverless option. Create a function file that exports the JSON Server instance as a handler.

Create [`netlify/functions/api.js`](https://github.com/typicode/json-server/blob/main/netlify/functions/api.js):

```javascript
const jsonServer = require('json-server')
const server = jsonServer.create()
const router = jsonServer.router(`${process.cwd()}/db.json`)
const middlewares = jsonServer.defaults()

server.use(middlewares)
server.use(router)

exports.handler = server

```

Add [`netlify.toml`](https://github.com/typicode/json-server/blob/main/netlify.toml):

```toml
[functions]
  directory = "netlify/functions"

```

Deploy via the Netlify CLI or Git integration.

## Cloud and Serverless Deployment

For enterprise-scale or pay-per-use models, deploy JSON Server to major cloud providers.

### AWS Lambda and Serverless Framework

Wrap the Express application from [`src/app.ts`](https://github.com/typicode/json-server/blob/main/src/app.ts) using `aws-serverless-express` or `@vendia/serverless-express`. Deploy using the Serverless Framework or AWS SAM to create a Lambda function with API Gateway.

### Google Cloud Run

Deploy the Docker image directly to Cloud Run. The platform automatically provisions containers and requires the application to listen on the `$PORT` environment variable. This provides automatic scaling and HTTPS termination.

### Azure App Service

Push your Node.js project or Docker image to Azure App Service. This platform supports continuous deployment from Git repositories and provides managed infrastructure for running JSON Server.

## Key Source Files and Architecture

Understanding the repository structure helps when customizing deployments. The core logic resides in:

- **[`src/app.ts`](https://github.com/typicode/json-server/blob/main/src/app.ts)**: Sets up the Express application, middlewares, and router. This is the programmatic entry point used when importing `json-server` as a module.
- **[`src/bin.ts`](https://github.com/typicode/json-server/blob/main/src/bin.ts)**: Parses command-line arguments and bootstraps the server. This is the CLI entry point used when running `npx json-server`.
- **[`package.json`](https://github.com/typicode/json-server/blob/main/package.json)**: Declares dependencies and scripts. Deployment platforms typically use the `start` script defined here.

These files demonstrate that JSON Server is a standard Node.js application, making it compatible with any hosting environment that supports Node.js.

## Summary

- **JSON Server** runs anywhere Node.js is supported, from local laptops to cloud servers.
- **Docker** provides the most portable deployment option, working across development, CI/CD, and production.
- **Heroku** requires a `Procfile` binding to `0.0.0.0` and the `$PORT` variable.
- **Vercel and Netlify** deploy JSON Server as serverless functions using wrapper scripts.
- **AWS Lambda, Google Cloud Run, and Azure** support enterprise-grade scaling and pay-per-use billing.
- The core architecture in [`src/app.ts`](https://github.com/typicode/json-server/blob/main/src/app.ts) and [`src/bin.ts`](https://github.com/typicode/json-server/blob/main/src/bin.ts) makes JSON Server fundamentally compatible with standard Node.js hosting patterns.

## Frequently Asked Questions

### How do I deploy JSON Server to Heroku?

Create a `Procfile` containing `web: npx json-server --watch db.json --host 0.0.0.0 --port $PORT`. Heroku automatically assigns the `$PORT` environment variable. Commit this file along with your [`db.json`](https://github.com/typicode/json-server/blob/main/db.json) and push to Heroku using Git.

### Can JSON Server run in a Docker container?

Yes. The repository provides a Dockerfile example using `node:20-alpine` as the base image. You copy your [`package.json`](https://github.com/typicode/json-server/blob/main/package.json) and [`db.json`](https://github.com/typicode/json-server/blob/main/db.json) into the container, install dependencies, and set the command to run `json-server` binding to `0.0.0.0`. This works on any Docker-compatible host.

### What are the key source files for customizing deployment behavior?

The main entry points are [`src/bin.ts`](https://github.com/typicode/json-server/blob/main/src/bin.ts) for CLI argument parsing and [`src/app.ts`](https://github.com/typicode/json-server/blob/main/src/app.ts) for the Express application setup. The [`package.json`](https://github.com/typicode/json-server/blob/main/package.json) file defines dependencies and start scripts. Understanding these files helps when wrapping JSON Server for serverless platforms or custom hosting environments.

### Is JSON Server suitable for production deployment?

JSON Server is designed primarily for prototyping, mocking, and development. While you can deploy it to production platforms like Heroku or AWS Lambda, it lacks built-in authentication, database persistence (it uses a flat JSON file), and horizontal scaling features required for high-traffic production applications.