
Mock Service Worker
A JavaScript API mocking library that shares request handlers between browser development and automated tests.

About Mock Service Worker
Mock Service Worker is an open source JavaScript library for mocking API requests. It lets developers describe network responses once, using request handlers written in the Fetch API style, and reuse those handlers across frameworks, tools, and environments.
In the browser, it uses the standard Service Worker API to intercept requests. In Node.js, it intercepts requests at the socket level through @mswjs/interceptors. The library can mock REST, GraphQL, Server-Sent Events, and WebSocket APIs under one contract. Its examples show integration with Playwright, Vitest-style test setup, and Storybook, and it can be enabled only in development builds.
Key features
- Shared request handlers for browser development and Node.js tests
- Mocks REST, GraphQL, Server-Sent Events, and WebSocket APIs together
- Handlers written with the Fetch API request and response model
- Browser request interception through the standard Service Worker API
- Node.js request interception through @mswjs/interceptors
- Generates request handlers from OpenAPI documents and HAR files
- Handlers use the Fetch API model, so the same mock code can be reused across tools
- One mock definition can cover browser development and Node.js test environments
- Free and open source
Mock Service Worker at a glance
- Website
- mswjs.io
- Category
- Development › APIs & Databases
- Type
- Online tool
- Pricing
- Free
- Open source
- Yes
- Last checked
- Oct 9, 2026 · Online when checked
- Listed
- Oct 9, 2026
Guides for APIs & Databases

Mock Service Worker alternatives
Tools and sites you could use instead, ranked by how closely they match.
An open-source HTTP mocking server for request matching, simulated responses and automated integration tests.
An HTTP mocking and proxy server with request expectations, response configuration and verification APIs.
HTTPie provides API testing clients for the terminal and desktop, with documentation and request workflows.
Compose and send HTTP requests with this REST testing interface, which includes method, endpoint, and request options.
Postman is an API development platform for sending requests, inspecting responses and maintaining collections and environments. Its Free plan covers individual API work, while shared team workflows and some automation features use paid plans.
Bruno is an API client that stores collections as local files for use with Git and other version-control workflows. The open-source edition handles personal request testing and collection runs; paid editions add integrations and in-app conveniences.
Popular in APIs & Databases
Well-known listings from the same topic.
Mock Service Worker FAQ
Can the same mocks be used in browser development and in tests?
Can handlers be generated from existing API definitions?
Can mocks return error responses?
Tell us and an editor will check it.
Claim the listing and suggest updates yourself. An editor checks every claim first.









