~ $ har-to-mocks ./your-file.har ./mocks

Record once.
Mock forever.

LaunchOctober 2021
Latestv3.0.0 — 18 Oct 2026
RuntimeNode.js ≥ 22
LicenseMIT, free forever

A command-line tool that turns the HAR file from your browser's Network tab into a folder of JSON mocks. Real responses, one file per endpoint, readable by MSW, Playwright, connect-api-mocker and Chrome DevTools Local Overrides.

No account, no config file, no signup. Nothing is written unless you give it an output folder, and --dry-run shows every file before it does.

Try it, it writes nothing.
$ npx har-to-mocks ./your-file.har ./mocks --dry-run
Star on GitHub ↗ Read the docs ↓ Watch the 2-minute demo ↗
Scroll ↓
har-to-mocks — dry run --dry-run · nothing written
$ har-to-mocks ./file.har ./mocks --url=api/service --method=GET --dry-run

Filtered requests:

 # │ Name          │ Method │ Path                        │ Query │ Status
 ──┼───────────────┼────────┼─────────────────────────────┼───────┼───────
 1 │ userRoles     │ GET    │ /api/service/userRoles      │       │ create
 2 │ currentUserId │ GET    │ /api/service/currentUserId  │       │ create
 3 │ active        │ GET    │ /api/service/clients/active │       │ create

Folder tree which will be applied:

└─ mocks
   └─ api
      └─ service
         ├─ userRoles
         │  └─ GET.json
         ├─ currentUserId
         │  └─ GET.json
         └─ clients
            └─ active
               └─ GET.json

No files were written. If you want to write files remove the (--dry-run) flag.

You already have the perfect mock data. It's in your Network tab.

The 30-second workflow

From DevTools to mock server
01

Export a HAR from DevTools

Open the Network tab, use your app, then "Export HAR..." in Chrome or "Save All As HAR" in Firefox. Include content so the responses are in the file.

02

Run har-to-mocks

Filter to the API calls you want, preview the table and the folder tree, then write one JSON file per endpoint.

npx har-to-mocks ./file.har ./mocks --url=/api
03

Point MSW, Playwright or Chrome at the folder

Load it with mocks-to-msw, mocks-to-playwright or connect-api-mocker, or select it in Chrome's Sources → Overrides. The UI now runs on your recorded responses.

Why not hand-write mocks?

Four ways mocks eat your time 01 / 04
01

Hand-written fixtures are slow and wrong

Typing JSON for a 40-field response means typos, missing fields, and shapes that drift from the real API. Recording the real response takes seconds and is exact by definition.

02

The backend is not ready, down, slow, or behind a VPN

Frontend work stalls. Recorded mocks let the UI run fully offline with production-shaped data.

03

Mocks live in several places

One set for dev, another for Storybook, another for tests. har-to-mocks produces one folder of JSON that MSW (dev, Storybook and tests), Playwright, connect-api-mocker, and Chrome overrides can all read.

04

Reproducing a bug needs the exact response

QA or a teammate exports a HAR from the broken session. You turn it into mocks and replay the exact state locally, or load it as a Chrome override on production without touching code.

Small CLI, careful defaults

Everything below is in v3.0.0 01 / 08
01

Filters

--url substring, --method (GET, POST, PUT, DELETE, PATCH), --type (xhr, fetch, document). Defaults: GET and xhr.

02

Dry run and status column

See create, update or skip per row and the exact folder tree, with [UPDATE] on files that already exist.

03

Interactive picker

-i gives a checkbox list with the focused endpoint's JSON response rendered below it (up to 12 lines), then a confirm step. ↑/↓ navigate, Space toggle, a all, i invert, Enter confirm.

04

--select for scripts and CI

Pick rows by number: --select=1,3,5-7. Interactive mode prints the equivalent value so you can replay the same choice later.

05

Duplicate detection

Requests that share path and method are marked skip, with a hint telling you how to keep the one you want.

06

Two output formats

mocks for MSW, Playwright and mock servers, chrome-overrides for Chrome DevTools Local Overrides.

07

Friendly errors

File not found, File is not valid JSON, File is not a valid HAR file. Unparsable URLs are skipped with a warning, not a crash.

08

Small bundled install

TypeScript, ES modules, bundled with esbuild into a single small install. Runs on Node.js 22 or newer.

Two output formats, same recording

--format=mocks (default)

Layout is <output>/<url path>/<METHOD>.json. Each file is the raw response body, nothing else: no headers, no status codes. This is the layout mocks-to-msw and mocks-to-playwright consume and connect-api-mocker (Express / webpack-dev-server middleware) serves.

Then do this
import { createMockHandler } from "mocks-to-msw";
import mocks from "./mocks/mocks";

const { mock } = createMockHandler<keyof typeof mocks>({ mocks, debug: true });

export const handlers = [
  mock.get("/client"),
  mock.post("/client/application", (data) => ({ ...data, modified: true })),
];

mocks-to-msw adds type-safe URL/method pairing, async loading, response modifiers, debug logging, origin configuration, and a CLI that generates a typed import file from the mocks folder.

Or in Playwright tests
import { createMockRoutes } from "mocks-to-playwright";
import mocks from "./mocks/mocks";

const { mock } = createMockRoutes<keyof typeof mocks>({ mocks });

test("shows the client", async ({ page }) => {
  await mock.get("/client")(page);
  await mock.post("/client/application", (data) => ({ ...data, status: "approved" }))(page);
  await page.goto("/");
});

mocks-to-playwright serves the same mocks through page.route() with the same typed API, works on a page or a whole browser context, and reads the same generated mocks.ts.

$ har-to-mocks ./file.har ./mocks --url=api/service --method=GET --dry-run

Folder tree which will be applied:

└─ mocks
   └─ api
      └─ service
         ├─ userRoles
         │  └─ GET.json
         ├─ currentUserId
         │  └─ GET.json
         └─ clients
            └─ active
               └─ GET.json

Who uses it, and for what

Pain · fix · command · format 01 / 10
01

Frontend developer blocked by the backend

format: mocks

The API is not ready, down, or behind a VPN. Record the app once against staging, generate mocks, keep building offline.

npx har-to-mocks ./staging.har ./src/mocks/api --url=/api --dry-run
# then the same command without --dry-run
02

Storybook author

format: mocks

Stories need realistic data. Generate mocks, wire them with mocks-to-msw, reuse the same handlers in the app and in Storybook. The Medium article covers this flow ↗

npx har-to-mocks ./file.har ./mocks --url=/api
03

Component and integration tests

format: mocks

Fixtures nobody updates. Deterministic responses from real traffic instead, served by MSW in Vitest, Jest, React Testing Library or Cypress, and by mocks-to-playwright in Playwright, all from one mocks.ts.

npx har-to-mocks ./file.har ./mocks --url=/api --method=GET --method=POST
04

Bug reproduction / QA handoff

format: mocks

QA attaches a HAR to the ticket. Run interactive mode, preview the responses, pick the failing call, replay it.

npx har-to-mocks ./ticket-4821.har ./mocks --interactive
05

Debugging production without a deploy

format: chrome-overrides

Replace any production response with a saved or edited one. Write an overrides folder, select it in DevTools. No proxy, no code change.

npx har-to-mocks ./prod.har ./overrides --format=chrome-overrides
06

Contractor onboarding to an unfamiliar codebase

format: mocks · the author's own story

Day one, no backend access. Record the running app, generate mocks, and have a fully working local frontend before you understand the backend.

npx har-to-mocks ./day-one.har ./src/mocks --url=/api --type=xhr --type=fetch --dry-run
07

Demo and sales environments

format: mocks

Freeze a known-good data set once so demos never depend on a live service.

npx har-to-mocks ./golden-demo.har ./demo/mocks --url=/api
08

Design handoff / prototyping

format: chrome-overrides

Designers and PMs see the UI with real data on a laptop with no backend access.

npx har-to-mocks ./app.har ./overrides --format=chrome-overrides
09

AI-agent workflows

format: mocks

Install the har-extraction skill and ask Claude Code: "Extract mocks from this HAR file for my API tests." Non-interactive flags, deterministic output, dry run and readable tables make the CLI agent-friendly.

npx skills add peterknezek/skills
10

REST query variants

format: mocks or chrome-overrides

?page=1 and ?page=2 hit the same path. The Query column plus --select or interactive mode let you keep the one you mean; chrome-overrides keeps both as separate files.

npx har-to-mocks ./file.har ./mocks --url=?page= --select=2

Works with: MSW, mocks-to-msw, Storybook, connect-api-mocker, Chrome DevTools, mocks-to-playwright, Playwright, Cypress via MSW, Node.js, TypeScript, Claude Code skill

How it compares

None of these tools are bad. har-to-mocks is simpler for one specific job: "I want JSON files from real traffic."

AlternativeWhat it doesWhy har-to-mocks is different
Playwright routeFromHARReplays a HAR inside Playwright testsOne HAR blob per test suite, hard to read or edit for a single test. har-to-mocks produces one JSON file per endpoint; mocks-to-playwright serves them in Playwright with typed routes and per-test modifiers, and the same files work in MSW, Storybook, Chrome and any mock server.
Hand-written MSW handlers / fixturesFull controlSlow, error-prone, drifts from the real API. har-to-mocks generates the data; you still write handlers if you want, or let mocks-to-msw do it.
har-to-stubby, MockServer HAR import, har-mock-server, @jmcorp/har2mocksConvert HAR to a specific server's format or run a replay serverTool-specific or server-bound. har-to-mocks is a files-first, tool-agnostic generator with preview, dry run, interactive picking, duplicate detection, and a Chrome DevTools format.
Chrome DevTools "Override content" by handEdit one response at a time inside DevToolsManual per request. har-to-mocks writes the whole override folder from a recording in one command.

Quality and trust

Is it maintained? Check for yourself
100%Test coverage. Unit, integration and snapshot tests with Vitest.
21Versions published between October 2021 and October 2026.
10+Releases in 2026 alone, v2.0.0 through v3.0.0.
MITNo web UI, no cloud service, no account, no telemetry beyond the npm update check.
How it is built
  • CI on every pull request: lint, tests, build.
  • Automated releases with semantic-release and conventional commits.
  • npm provenance: publishes are OIDC-signed from GitHub Actions.
  • TypeScript, ES modules, @oclif/core v5, @inquirer/prompts, ESLint + Prettier.
  • Snyk and Socket list the package as MIT licensed with no reported vulnerabilities; Snyk rates maintenance as "sustainable".
Release timeline
  1. 18 Oct 2026
    v3.0.0 — latest
    Node.js ≥ 22.
  2. 2026
    v2.x series
    Interactive mode, response preview, Chrome overrides format, --select, friendly errors, security dependency bumps. Node.js ≥ 18.
  3. 24 Oct 2021
    First published on npm
    Built for the author's own client work.
Full changelog on GitHub releases ↗

A small, real community

No invented testimonials

"Hi, I am currently really liking how easy it is to get json responses from the HAR network traffic file."

"Hi again, this tool has been very helpful." … "Thanks again for all the support."

On GitHub

Starred and forked by a small group of developers, and adapted by others (for example huihao/har-to-msw-mocks). Good first issues welcome.

★ Star on GitHub
Listed in skill directories

skills.sh, playbooks.com and tomevault.io list the author's har-extraction skill, describing the pipeline as HAR File → har-to-mocks → JSON Mocks → mocks-to-msw → MSW Handlers → Storybook/Tests.

Share your experience

Used it? Share your use case in the GitHub discussion or post on X and tag @peter_knezek. Real quotes will replace this box over time.

Join the discussion

Built by

Independent contractor · Working globally

Peter Knezek

Senior software engineer and independent contractor focused on React, Next.js and TypeScript, with a current interest in agentic engineering and AI-assisted workflows. He created and maintains har-to-mocks, mocks-to-msw, mocks-to-playwright and the har-extraction agent skill.

Built from real client projects, not a demo: he kept needing realistic frontend mocks without waiting on backends, wrote this tool for that, and has maintained it publicly since 2021.

For engagementsOpen to contracting ↗
GitHubgithub.com/peterknezek ↗ LinkedInin/peterknezek ↗ X@peter_knezek ↗ MediumStorybook API mocking with mocks-to-msw ↗ YouTube2-minute demo (v1.1.1) ↗

Questions developers ask first

Including what it does not do yet
Q1

Will it overwrite my files?

Not silently. Without an output folder nothing is written. With one, the Status column tells you what will be created, updated or skipped, --dry-run shows the full tree first, and interactive mode asks for confirmation.

Q2

My HAR has 600 entries.

Narrow it with --url, --method and --type, then pick rows with the interactive picker or --select=1,3,5-7.

Q3

I use GraphQL.

Requests are keyed by URL path and method, so multiple GraphQL operations on one endpoint collide today (open issue #12). Interactive mode and --select let you pick which one to keep. Operation splitting is not implemented.

Q4

Same endpoint, different query params?

The Query column shows them apart. The chrome-overrides format writes separate files per query string; in the mocks format use --select or interactive mode to choose. Automatic handling is tracked in open issue #18.

Q5

Why don't I see my fetch requests?

The default resource type is xhr and the default method is GET. Pass --type=fetch (and --method=POST etc.) to include them. --url is a case-sensitive substring match, not a regex.

Q6

Does it leak secrets?

HAR files can contain cookies and tokens. The mocks keep response bodies only, no headers. Still, review the output before committing it.

Q7

Can I use the mocks in Playwright without MSW?

Yes. mocks-to-playwright ↗ registers them with page.route(): await mock.get("/client")(page). It uses the same mocks.ts as mocks-to-msw, so one set of mocks feeds Storybook, the app and your end-to-end tests.

Docs

Full CLI reference, every feature with its real output, the HAR export guide for Chrome, Firefox and Safari, FAQ, and the changelog.

CLI reference→ Features with output→ How to get a HAR file→ FAQ→ Changelog↗
har-to-mocks --help
har-to-mocks <file.har> [output-folder] [flags]

  -u, --url          substring match in the full URL (case-sensitive)
  -m, --method       GET | POST | PUT | DELETE | PATCH   (default: GET)
  -t, --type         xhr | fetch | document             (default: xhr)
  -f, --format       mocks | chrome-overrides           (default: mocks)
  -s, --select       rows by # column, e.g. 1,3,5-7
  -i, --interactive  checkbox picker with response preview
      --dry-run      show tables and folder tree, write nothing
  -v, --version
  -h, --help

Install globally: npm install -g har-to-mocks