What Is a HAR File? Read, Share and Replay One
A HAR file (HTTP Archive, extension .har) is a recording of everything a page asked the network for: every request, its headers and body, every response, and how long each one took. It is plain JSON, every browser can export one, and it is the most useful attachment a "it doesn't work for me" bug report can carry.
This guide covers what is inside one, how to export it, how to read it, what to remove before you share it, and how to replay it so the page gets the recorded responses again.
What a HAR file is forโ
The Network tab shows you your own session. A HAR file is that session saved to disk, so someone else can look at it. Teams use it to:
- Debug a bug they can't reproduce. A user or a tester records the HAR while the bug happens. You see the exact request that failed, with its status, headers and response.
- Find what makes a page slow. Every request carries its timings, so the slow API call or the oversized script stands out.
- Hand evidence to a vendor. Support teams for APIs, CDNs and SaaS tools routinely ask for a HAR, because it answers most of their first questions.
- Rebuild a scenario. The recorded responses can be served again, to test the frontend against exactly what the server said that day (more on that below).
What is inside a HAR fileโ
A HAR is one JSON object, log, defined by the HAR 1.2 spec. The parts you will actually read:
| Field | What it holds |
|---|---|
log.creator, log.browser | The tool and browser that recorded the file, with versions |
log.pages | Each page load: its title, start time and load timings |
log.entries | One entry per request, the heart of the file |
entries[].request | Method, URL, HTTP version, headers, cookies, query string and the body sent (postData) |
entries[].response | Status, headers, cookies, redirect URL and the body received (content.text, with its mimeType) |
entries[].timings | The time spent in each phase: blocked, dns, connect, ssl, send, wait, receive |
A trimmed entry looks like this:
{
"request": { "method": "GET", "url": "https://api.example.com/orders?page=1", "headers": [] },
"response": {
"status": 200,
"content": { "mimeType": "application/json", "text": "{\"orders\":[]}" }
},
"timings": { "blocked": 2, "dns": 0, "connect": 0, "send": 0, "wait": 184, "receive": 3 }
}
wait is the time to first byte: how long the server took to answer. When a page feels slow, it is usually the first timing to look at.
How to export a HAR fileโ
Chrome and Edge
- Open DevTools (F12, or โ + โฅ + I on a Mac) and go to the Network tab.
- Tick Preserve log if the bug spans a navigation or a redirect, then reload the page and reproduce the problem.
- Click the Export HAR button (the down arrow in the Network toolbar), or right-click any request and pick the export option.
Recent Chrome versions export a sanitized HAR by default, without cookies and authorization headers. Exporting those too needs a setting in DevTools, and you should only turn it on when the person receiving the file really needs them. Our Network tab guide covers the rest of the panel.
Firefox
Open the Network panel, reproduce the problem, then right-click any request and choose Save All As HAR.
How to open and read a HAR fileโ
- In the browser. Drag the
.harfile onto the Network tab of Chrome or Edge DevTools, or use Import HAR file (the up arrow). Every request appears as if you had recorded it yourself, with filters, the waterfall and the response previews. - In a HAR viewer. Google's HAR Analyzer and similar tools show the same list in a web page, which helps when the file comes from a browser you don't have.
- In an editor. It is JSON: search it for a URL, a status code or an error message. Large files are easier with
jq, for examplejq '.log.entries[] | select(.response.status >= 400) | .request.url' session.harlists every failed request.
What to look for first: requests in red (status 4xx and 5xx), a wait far above the others, the same request sent twice, and redirects you didn't expect.
Before you share a HAR fileโ
A HAR is a copy of the session, and the session may include secrets. Before you attach one to a ticket:
- Search it for
cookie,authorization,token,api_keyandpassword. - Remember the bodies: a HAR from a checkout or a profile page contains what the user typed and what the server sent back.
- Prefer the sanitized export, and record with a test account when you can.
- If you received one, treat it like a credential: delete it when the bug is fixed.
Replay a HAR file with tweakโ
Reading a HAR tells you what the server said. Replaying it lets you test the frontend against it, when the bug depends on data you don't have, or the backend has changed since.
tweak imports a .har file and turns each recorded request into a mock rule:
- Keep only the API calls (see the note below).
- In tweak, open the more options menu (the three dots, top right) and choose Import.
- Pick or drop the
.harfile on the import page. - Each entry with a response becomes a rule, labelled with its position and host (
[3] Request to api.example.com), with the recorded URL, method, status code and response body, the request body it was sent with, and a delay equal to the recorded serverwait, so the replay is as slow as the original. - Keep the rules you need, switch off or delete the rest, and reload the page. The page now gets the recorded responses, and the server is not called.
Keep only the API calls first. Today tweak refuses the whole file when one response has a type it does not recognise, and a real export almost always has one: Chrome and Edge write x-unknown for a response without a type (a CORS preflight, a tracking beacon), and Firefox adds the charset (application/json; charset=utf-8). We are fixing the import. Until then, this jq command keeps the JSON responses and writes a file tweak imports:
jq '.log.entries |= map(select(.response.content.mimeType | startswith("application/json")) | .response.content.mimeType = "application/json")' session.har > api-calls.har
It is usually what you want anyway: the API calls are what a frontend test replays, not the page's scripts and images.
From there, each rule is an ordinary mock: change the response body to test an edge case, set the status to 500 to see the error state, or remove the delay. The import and export docs cover the details, and How to Mock API Calls covers mocking in general.
Importing a HAR is free on every plan. A HAR often holds dozens of requests, and the free plan holds 12 rules, so keep only the requests the bug needs.
FAQโ
What is a HAR file?
A HAR (HTTP Archive) file is a JSON file, with the .har extension, that records every network request a page made while it was recorded: the URL, method, headers, cookies, the response status and body, and how long each phase of the request took. Browsers export one from the Network tab of their developer tools.
How do I open a HAR file?
Drag it onto the Network tab of Chrome or Edge DevTools, or use its Import HAR file button, and the requests appear as if you had recorded them. Firefox opens one from the Network panel too. Any text editor also opens it, since it is plain JSON.
Is it safe to share a HAR file?
Only after you have read it. A HAR can hold cookies, Authorization headers, tokens and whatever the pages sent and received, personal data included. Recent Chrome versions leave cookies and auth headers out by default; still search the file for tokens and personal data, and remove them before you attach it to a ticket.
Can I replay a HAR file?
Yes. Import the .har file into tweak and each recorded request becomes a mock rule with the recorded URL, method, status, response body and server wait time. The page then gets the recorded responses instead of the live ones. Today tweak refuses a file holding a response type it does not recognise, so keep only the JSON API calls before you import it. Importing a HAR is free on every plan.
Summaryโ
A HAR file is the Network tab saved as JSON: every request, response and timing of a session. Export it from DevTools, read it there or with jq, and clean it of cookies and tokens before you share it. To test against what the server said, import it into tweak and replay it as mock rules.
If you liked this article, consider sharing (tweeting) it to your followers.
Need something else? Request a feature