How to import a HAR file in API Spector

Roy de Kleijn Roy de Kleijn · · 2 min read
How to import a HAR file in API Spector

A HAR, short for HTTP Archive, is the request and response capture format that browser devtools and proxies export. If you can watch a call happen in the Network tab, you can turn it into a saved request. API Spector imports a HAR and keeps the parts that matter.

Capture a HAR

In Chrome, Edge, or Firefox, open devtools and go to the Network tab. Reload the page or click through the flow you want to capture, then export:

  • Chrome and Edge: right-click any row and choose Save all as HAR with content, or use the download icon.
  • Firefox: right-click a row and choose Save All As HAR.

Proxies export HAR too, including Charles, mitmproxy, and Fiddler, so you can capture traffic from a mobile app or a backend service the same way.

Import it

Open Import in the toolbar, choose HAR, and pick the .har file.

A HAR is a flat log, and most of it is noise: images, CSS, JavaScript, fonts, and the same call repeated many times. API Spector keeps the API-like requests (the XHR and fetch calls, or, when the capture does not mark them, the ones whose content type is not a static asset), drops the static files, and collapses duplicate calls. What is left is grouped by host into folders.

Pick what to keep

Because a capture can still hold more than you want, the import opens the endpoint picker. You see the captured requests grouped by host, you tick the ones to keep, and you can extract the shared base URL into an environment variable so the requests read {{baseUrl}} instead of a hard-coded host. Then import.

What comes across

  • Method and URL exactly as captured.
  • Bodies: JSON, form-urlencoded, and raw bodies are mapped to the right body mode.
  • Headers that matter, such as Authorization and Content-Type. Cookies and transport headers like Content-Length and Host are dropped on purpose, so session cookies are never written into the collection file.

The result is a set of real, runnable requests built from traffic you already made, ready to send, save, and put under version control.

Try it in API Spector

Free and open source. No account needed to use the app.

Keep reading