How to Capture a HAR File in Chrome, Edge, Firefox, Safari

Step by step for each browser and phones, what the sanitized export still leaks (passwords, tokens, bodies), and a jq redaction tested before sharing.

By · · 10 min read

Illustration for How to Capture a HAR File in Chrome, Edge, Firefox, Safari

Support has asked for a HAR file of the page that fails, and the file you send will hold everything your browser said to that site. In Chrome or Edge: open DevTools, go to Network, tick Preserve log, reproduce the problem, then click Export HAR (sanitized).... In Firefox: Network, tick Persist Logs, reproduce, then use Save All As HAR. In Safari: turn on Show features for web developers, open the Web Inspector's Network tab, reproduce, and click Export. Before sending it, know that even Chrome's sanitized export keeps passwords typed into forms, tokens in URLs and every response body. The redaction section shows a jq pass that removes them. The HAR File Analyzer reads the result in your browser without uploading it.

Before you record: three settings that decide what the file holds

SettingChrome and EdgeFirefoxSafariWhy it matters
Keep requests across navigationsPreserve logPersist LogsPreserve LogLogins and checkouts redirect. Without it, the log clears on each page load and the failing request is gone.
Bypass the cacheDisable cachethe disable-cache checkboxIgnore CacheReproduces a first visit. Chrome marks cached responses with _fromCache (memory or disk).
Start recording before the actionDevTools open firstNetwork Monitor open firstWeb Inspector open firstChrome's reference says DevTools records requests only "so long as DevTools is open". Requests from before that are missing.

In Safari, WebKit's Network tab docs say Ignore Cache applies "so long as Web Inspector is open". For a whole flow such as a login, start from a signed-out tab and clear the log first. Stop as soon as the error appears, because every extra click adds requests someone has to read past.

Chrome

  1. Open DevTools (F12 on Windows and Linux, Cmd+Option+I on macOS) and select Network.
  2. Tick Preserve log, and Disable cache if the bug is about a first visit.
  3. Click Clear, then reload or perform the failing steps.
  4. Click Export HAR (sanitized)... in the action bar. To take only the requests a filter shows, right-click one and choose Copy all listed as HAR (sanitized), then paste into a .har file.

Since Chrome 130 the export is sanitized by default. The "What's new in DevTools (Chrome 130)" post says HAR files "will no longer contain Cookie, Set-Cookie, and Authorization headers by default". To get the full file, turn on Settings > Preferences > Network > Allow to generate HAR with sensitive data. Then use the drop-down beside Export and pick Export HAR (with sensitive data). Only do this when the person debugging needs to replay the session. The full file is a working login.

The source shows exactly what sanitizing removes. In DevTools' models/har/Log.ts, the sanitize branch empties request.cookies and response.cookies. It drops request headers named authorization or cookie and response headers named set-cookie, comparing names case-insensitively. It also omits the data of server-sent event messages. Everything else stays:

  • Request bodies (postData.text): the password in a login form.
  • Response bodies (content.text, base64 for binary): the JWT a login API returns, plus every JSON payload. Writer.ts writes the body text whenever DevTools has it.
  • URLs and query strings: ?access_token=... or a magic-link token.
  • Other headers: X-Api-Key, Proxy-Authorization and custom auth headers. Only the exact names above are removed.
  • WebSocket frames (_webSocketMessages): kept with their text even when sanitized.

Edge

Edge uses the same DevTools. Microsoft's Network reference describes the same flow, including Export HAR (sanitized) in the action bar. It names the same setting, Allow to generate HAR with sensitive data, under Settings > Preferences > Network. It also documents Copy > Copy all as HAR (sanitized) for pasting into a ticket, which carries the same risks as the file.

Firefox

  1. Open the Network Monitor with Ctrl+Shift+E (Cmd+Opt+E on a Mac).
  2. Tick the checkbox that disables caching if needed, and in the toolbar's menu of other actions turn on Persist Logs.
  3. Reproduce, then choose Save All As HAR from that menu or the request list's context menu. Copy All As HAR puts the same JSON on the clipboard.

Firefox has no sanitized export. Its har-builder.js copies request headers, cookies and post data as captured, with no sanitize step. Its preferences, in about:config, decide the rest. These are the defaults from Firefox's firefox.js:

PreferenceDefaultEffect
devtools.netmonitor.har.includeResponseBodiestrueSet false to leave bodies out, the biggest size and privacy cut.
devtools.netmonitor.har.enableAutoExportToFilefalseWrites a HAR automatically when a page loads, for repeat runs.
devtools.netmonitor.har.defaultLogDiremptyWhere auto-exported files go.
devtools.netmonitor.har.defaultFileName%hostname_Archive [%date]The file name pattern.
devtools.netmonitor.har.compressfalseZips the exported file.

Safari

  1. Safari > Settings > Advanced, tick Show features for web developers. That is the wording on WebKit's and Apple's current pages.
  2. Open the Web Inspector with Develop > Show Web Inspector (Option+Cmd+I) and select Network.
  3. Tick Preserve Log, and turn on Ignore Cache if needed.
  4. Reproduce, then click Export (or press Cmd+S) to save the HAR.

WebKit documents Import, or a drag onto the inspector, to reopen a saved HAR. Like Firefox, Safari has no sanitize option, so treat its export as a full one.

Phones and tablets

  • Android, Chrome: enable USB debugging on the phone, connect it by cable, and open chrome://inspect#devices on the computer. Click inspect under the tab and use the Network panel as above. Google's remote debugging page notes that the phone's Chrome version sets the DevTools version you get.
  • iPhone and iPad, Safari: on the device, Settings > Safari > Advanced > Web Inspector. Connect it to a Mac by cable, or by Xcode's wireless debugging, and the device appears as a submenu of Safari's Develop menu on the Mac. Pick the page, then export from its Network tab.

For native apps that do not use a web view, a HAR is the wrong file. Capture packets through the network packet capture guide, whose rvictl section covers iOS.

What a HAR contains, and how to redact it

A HAR is JSON. Its fields follow the HTTP Archive 1.2 draft. The draft's page, dated 14 August 2012, now says "DO NOT USE" and that it was never published by the W3C and has been abandoned, yet Chrome, Firefox and Safari all export it. Each entry carries the full URL with a parsed queryString, request and response headers and cookies, postData, response.content.text, and timings, where -1 means the phase did not apply.

The worked example is a 5-request login flow built for this guide on documentation domains, kept in the test fixtures. It is shaped like Chrome's "with sensitive data" export: a session cookie, a login POST with a password, a JWT in the login response, a bearer call with ?access_token= in its URL, and an API-key header. Counting how often each secret appears in the file:

Secret in the flowFull exportAfter Chrome's sanitize rulesAfter the jq redaction
sid session cookie400
session cookie set at login400
JWT (Authorization header and login response)210
password in the login POST110
access_token in the URL220
X-Api-Key value110
customer email330
file size9,777 bytes8,526 bytes9,191 bytes
Which parts of a HAR entry Chrome's sanitized export removes and which it keeps: Cookie, Set-Cookie, Authorization and cookie arrays removed; post bodies, response bodies, URLs, query strings, other headers and WebSocket frames kept
Which parts of a HAR entry Chrome's sanitized export removes and which it keeps: Cookie, Set-Cookie, Authorization and cookie arrays removed; post bodies, response bodies, URLs, query strings, other headers and WebSocket frames kept

The middle column applies DevTools' own sanitize rules. Five secrets survive it, the password included. The redaction below replaces values with REDACTED instead of deleting entries, so timings, statuses and sizes stay intact:

jq 'def scrub: .value = "REDACTED";
.log.entries |= map(
  .request.headers |= map(if (.name | ascii_downcase | test("^(authorization|proxy-authorization|cookie|x-api-key)
quot;)) then scrub else . end) | .response.headers |= map(if (.name | ascii_downcase) == "set-cookie" then scrub else . end) | .request.cookies |= map(scrub) | .response.cookies |= map(scrub) | .request.queryString |= map(scrub) | .request.url |= sub("\\?.*
quot;; "?REDACTED") | if .request.postData then .request.postData.text = "REDACTED" else . end | if .response.content.text then .response.content.text = "REDACTED" else . end)' full.har > redacted.har

Add your own header names to the test(...) list. Check the result with grep -c for each token you know was in the session. Redaction did not change the diagnosis: the HAR File Analyzer printed the same summary for both files. It reported 5 requests · 1.2 KiB transferred (334 B decoded) · 6.4s span and named the slowest request, 5056 ms 503 api.example.com/v1/recommendations. Timings and statuses are what support usually needs. Bodies seldom are.

Why this matters: Okta's 2023 root-cause report says HAR files uploaded to its support system "contained session tokens which could in turn be used for session hijacking attacks". The attacker used them to hijack the sessions of five customers.

File size

A HAR has no compression and no size cap in Chrome's writer. Writer.ts streams the JSON in 100,000-character chunks and caps nothing. Response bodies dominate, and binary ones are base64-encoded, which costs 4 bytes for every 3. A page with video or large images can produce a HAR of hundreds of megabytes. To keep it small, filter the Network panel to the failing requests and use Copy all listed as HAR (sanitized). In Firefox, set includeResponseBodies to false.

When the problem is below HTTP (DNS, TLS, proxies), chrome://net-export records a NetLog instead. The Chromium page says its default strips private information, and that captures including raw bytes "may include personal information".

Which method for which situation

SituationUse
Support wants to see a failing pageChrome or Edge, Preserve log, Export HAR (sanitized), then the jq redaction
The engineer must replay the sessionthe with-sensitive-data export, sent by a secure channel and deleted after
A login or SSO flow across domainsPreserve log or Persist Logs on, start signed out
First-visit slownessDisable cache or Ignore Cache, open tools before loading
Firefox-only bugSave All As HAR, includeResponseBodies false if bodies are not needed
Safari or iOS-only bugWeb Inspector Network tab, Export, with the device attached to a Mac
Android-only bugchrome://inspect#devices remote debugging
A native app or a socket problema packet capture, not a HAR

Tools for this job

  • HAR File Analyzer: drop the .har. It shows totals, third-party share, time per phase, the slowest and heaviest requests, and errors, parsed locally so the cookies never leave your machine.
  • PCAP File Inspector: for when the question is packets rather than requests, such as a native app or a TLS failure before HTTP starts.

The HAR, GC log and SQLite reading guide explains what the timings and the third-party share mean once you have the file. When the page is slow because a Node backend is swapping, how to take a Node.js heap snapshot captures the server side. For a Go backend, how to collect Go pprof profiles does the same.

Frequently asked questions

Is a sanitized HAR safe to share?

Safer, not safe. Chrome's sanitized export removes Cookie, Set-Cookie and Authorization headers and the cookie lists. It keeps request bodies, response bodies, URLs with their query strings, custom auth headers and WebSocket frames. Passwords typed into forms and tokens returned by login APIs survive it.

Why is my HAR file empty or missing requests?

DevTools records only while it is open, so requests made before you opened it are not in the file. Navigations clear the log unless Preserve log (Persist Logs in Firefox) is on. A filter left in the Network panel also limits what Copy all listed copies.

How do I make a HAR file smaller?

Filter the request list to the failing calls and export only those. In Firefox, set devtools.netmonitor.har.includeResponseBodies to false. Otherwise remove bodies afterwards with jq. Binary responses are stored as base64, which adds a third to their size.

Can I open a HAR file again later?

Yes. Chrome and Edge import a HAR by drag-and-drop onto the request table or the Import HAR button. Safari has Import, and Firefox has Import HAR in the Network Monitor's menu. The HAR File Analyzer reads it without a browser's DevTools at all.

Sources and further reading

Browse all tools