When you are debugging an API you often want to re-run a single request from the command line. This tool takes a HAR (HTTP Archive) export from your browser’s Network panel and rebuilds each entry as a curl command — correct method, every header, and the request body — so you can paste it into a terminal and reproduce the call exactly. It runs entirely in your browser, which matters because HAR files routinely contain auth tokens and cookies.
When to use HAR-to-cURL
The browser’s “Copy as cURL” context-menu option does the same thing for a single request, but it is not always available (some browsers omit it, some requests are filtered out of the Network panel’s copy menu) and it does not help when you need to replay a batch of requests or when you captured a HAR file from a remote session. The HAR-to-cURL converter lets you:
- Convert a full API session — load a HAR with dozens of calls and replay the specific one you need without clicking through the Network panel again
- Share reproducible examples — extract a cURL command from a colleague’s HAR file without giving them access to your machine or the Network panel
- Feed into automation — pipe a cURL command into a test script, a CI job, or an HTTP client library for comparison testing
- Debug without a browser — reproduce a complex POST with the exact headers and body the browser sent, outside the browser environment
How it works
The HAR is parsed with JSON.parse; each item in log.entries has a request with a method, url, a headers array, and optionally postData.text. The converter emits curl -X METHOD 'URL', adds one -H 'Name: Value' per header (skipping HTTP/2 pseudo-headers like :authority that cURL sets itself), and appends --data-raw '…' when there is a body. Every quoted value is made shell-safe by escaping single quotes as '\''. If the request carried Accept-Encoding, the --compressed flag is added so cURL decodes gzip or brotli the same way the browser did.
Exporting a HAR file
- Open Chrome or Firefox DevTools (F12)
- Go to the Network tab
- Reproduce the requests you want to capture
- Right-click anywhere in the request list and choose Save all as HAR with content (Chrome) or Save All as HAR (Firefox)
- Load the resulting
.harfile into this tool
Tips and security notes
- Use the URL filter to isolate one endpoint when a HAR contains hundreds of requests (analytics, fonts, images, and so on).
- The generated command embeds whatever auth the browser sent — a
CookieorAuthorizationheader is a live credential. Scrub it before pasting into documentation, sharing with a colleague, or committing to a repo. - HTTP/2 pseudo-headers (
:method,:path,:scheme,:authority) are omitted because cURL derives them from the URL and method automatically. - HAR files can be large — a single page load often captures several hundred requests. Paste the JSON or load the file; the converter handles the entire
entriesarray.