How to create a HAR file in Chrome, and remove tokens before you share it
Updated · 8 min read
To create a HAR file in Chrome, open DevTools on the Network panel, check Preserve log and Disable cache, reproduce the problem, then click Export HAR (sanitized)... in the Network panel's action bar. Chrome saves a .har file with every request the tab made while DevTools was open. The steps below take about two minutes, and the rest of this guide covers the export options, other browsers, and how to clean the tokens Chrome leaves in the file before you send it to support.
Steps
- 1
Open DevTools on the Network panel
Go to the page where the problem happens. Press F12,
Ctrl+Shift+Ion Windows and Linux, orCmd+Option+Ion macOS, and click the Network tab. Open it before you reproduce anything, because Chrome only logs requests while DevTools is open. - 2
Check Preserve log and Disable cache
In the Network panel's action bar, check Preserve log so the list survives reloads, redirects and logins. Check Disable cache so the browser fetches everything again instead of serving it from cache.
- 3
Clear the log and reload
Click the clear button (the circle with a line through it) in the action bar, then reload the page. The file then starts with a clean page load and nothing unrelated.
- 4
Reproduce the problem
Repeat the exact steps that trigger the issue: click the button, submit the form, wait for the error. Keep DevTools open the whole time and stop once the problem has happened.
- 5
Export the HAR file
Clear any text in the Filter box and select All, so nothing is hidden. Then click the download icon, Export HAR (sanitized)..., and save the
.harfile. You can also right-click any request and choose Save all as HAR (sanitized). - 6
Check the file before you send it
Open the file in a text editor and search for
token,key,password,secret,eyJand your email address. The sanitized export removes cookies and the Authorization header, but other secrets can still be in it.
Export HAR (sanitized) or with sensitive data?
Since Chrome 130, the default HAR export is sanitized. It leaves out three headers: Cookie, Set-Cookie and Authorization. Everything else is kept, including query strings, request bodies and response bodies.
For a support ticket, the sanitized file is almost always what you want. The person reading it needs URLs, status codes, timings and error responses, and the sanitized file has all of them. Send the version with sensitive data only when someone is debugging the auth flow itself and asks for it.
To get that version, open DevTools Settings (the gear icon or F1), go to Preferences > Network and check Allow to generate HAR with sensitive data. The Export button then shows a small arrow. Long-click it and choose Export HAR (with sensitive data). The Network features reference has the current labels.
Why your HAR file is empty or missing requests
Most bad HAR files come from one of these:
- DevTools was opened after the problem happened. Chrome does not log in the background, so the requests you needed were never recorded. Open DevTools, then reproduce.
- Preserve log was off. A redirect or login cleared the list, and the file only holds the last page.
- A filter was still set. If the Filter box has text in it or a type like Fetch/XHR is selected, clear it before exporting so the file includes every request.
- The flow opened a popup or a new tab, as many single sign-on logins do. Those requests show up in that tab's own DevTools. Turn on Auto-open DevTools for popups in DevTools Settings, or open DevTools in the new tab before you continue.
- The cache answered. Without Disable cache, files the browser already has never reach the network again, so the timings don't match what a first-time visitor sees.
How to get a HAR file in Edge, Firefox and Safari
- Microsoft Edge runs the same DevTools as Chrome. The steps and labels above apply as written.
- Firefox: open the Network Monitor with
Ctrl+Shift+EorCmd+Option+E. Check Disable Cache in the toolbar, and turn on Persist Logs from the gear menu at the right of the toolbar. Reproduce the issue, then choose Save All As HAR from the same menu. See the Firefox Network Monitor toolbar docs. - Safari: turn on Show Develop menu in Safari Settings > Advanced, then choose Develop > Show Web Inspector. In the Network tab, turn on Preserve Log, reproduce the issue and click Export.
Firefox and Safari write cookies and Authorization headers into the file along with everything else, so the cleanup steps below matter even more there.
What's sensitive in a HAR file
A HAR file records the request and response of every call, so it carries whatever credentials the app sends. Chrome's sanitized export only covers the first item on this list:
- Cookies and auth headers:
Cookie,Set-CookieandAuthorization: Bearer .... Chrome removes these by default. Firefox and Safari keep them. - Custom headers:
X-Api-Key,X-CSRF-Token,X-Auth-Tokenand similar. Chrome keeps them in a sanitized export. - Tokens in URLs:
?access_token=,?api_key=, OAuth?code=values on redirects, signed URL signatures and magic-link tokens. They appear in the request URL, thequeryStringlist,RefererandLocationheaders. - Request bodies: a login request holds the password in plain text, and token refresh calls carry the refresh token.
- Response bodies: login responses often return new access tokens, and most API responses contain personal data such as names, emails and addresses.
If you have a JWT in the file and want to see what it reveals, decode it locally in Chrome instead of pasting it into a website.
How to scrub a HAR file before sending it to support
Start by recording less. Log in first, then clear the log and reproduce only the failing steps. A short file has fewer secrets to find and is easier for support to read.
Then remove what you can. Google's HAR Analyzer can download a redacted copy of a file. If you have jq installed, this command drops cookie, auth and API key headers and empties the cookie lists:
jq '.log.entries[] |= (
.request.headers |= map(select(.name | test("^(cookie|authorization|x-api-key)$"; "i") | not))
| .response.headers |= map(select(.name | test("^set-cookie$"; "i") | not))
| .request.cookies = []
| .response.cookies = []
)' session.har > session.scrubbed.harHeaders are the easy part. Tokens in URLs and bodies are still there, so search the result before you send it:
grep -n -i -E 'token|secret|password|api[_-]?key|bearer|eyJ' session.scrubbed.harEvery line this prints is something to check. Replace the value with a placeholder in a text editor, or record again without the step that produced it. Tokens you could not remove expire if you log out or rotate the key after support is done.
Create a sanitized HAR file with Netraptor
Chrome's sanitized export stops at three headers. Netraptor, a free Chrome extension, adds its own Network panel to DevTools with a HAR export that also cleans URLs and bodies. It records the inspected tab as soon as you open the Netraptor panel and keeps requests across reloads and redirects, so there is no Preserve log to forget.
To save a HAR file, right-click any request in Netraptor's Requests tab and choose Save all as HAR (sanitized). It saves the rows currently listed, so your filter, the type chips and Hide noise all apply. Filter to the failing calls first and the file stays small. The sanitized file:
- Drops every request and response header with a credential-like name:
Authorization,Proxy-Authorization,Cookie,Set-Cookie, and any name containing token, secret, password, session, auth, csrf, xsrf, jwt, bearer, signature, credential or key, which coversX-Api-KeyandX-CSRF-Token. - Replaces matching query and fragment parameters with
[redacted], plus OAuthcodevalues. This applies to the request URL and toReferer,Locationand initiator URLs. - Redacts matching fields at any depth in JSON request and response bodies, and in form-encoded request bodies.
- Removes bodies it cannot parse, such as HTML, plain text and binary data, and marks them
Removed by Netraptor sanitized export.
When you need the unsanitized file for your own debugging, use Copy > Copy all as HAR in the same right-click menu, which copies the listed requests to the clipboard. Or open the Export tab, pick HAR and uncheck Strip auth headers and cookies. The Export tab exports the whole session, and that checkbox runs the same sanitizer when it is on, which is the default.
Two limits worth knowing. Netraptor keeps each body up to 1 MB and marks larger ones as truncated. It stores API response bodies as they arrive, but script and stylesheet bodies only once you open them. For a full page-load waterfall with every asset body, Chrome's own export is the better file. HAR export is on the Free plan and the data stays in your browser.
What to do with the HAR file next
To read the file yourself, import it back into the Network panel, open it in a viewer or query it with jq. See how to open and analyze a HAR file. For background on the format and what each field means, see what a HAR file is.
Frequently asked questions
- How do I generate a HAR file in Chrome?
- Open DevTools with F12, go to the Network panel, check Preserve log, reload the page and reproduce the problem. Then click Export HAR (sanitized)... in the action bar to save the
.harfile. - Where is the HAR file saved?
- Chrome asks where to save it, and suggests your Downloads folder by default. The file name is usually the site's host name with a
.harextension. - What does sanitized mean in Chrome's HAR export?
- Since Chrome 130, the sanitized export leaves out the Cookie, Set-Cookie and Authorization headers. Tokens in URLs, custom headers like X-Api-Key, and request and response bodies are still included.
- Is it safe to send a HAR file to support?
- It is reasonably safe once you have cleaned it. Use the sanitized export, record only the steps that reproduce the issue, and search the file for tokens and passwords first. Log out afterwards so any session left in the file stops working.
- Why is my HAR file so big?
- It includes every image, script and response body the tab loaded. Clear the log, then record only the failing steps. In Netraptor, filter to the requests you need before you save, since only the listed rows go into the file.
- Can I create a HAR file on a phone?
- Not in the mobile browser itself. Connect an Android phone to desktop Chrome with remote debugging at
chrome://inspect, or an iPhone to Safari's Web Inspector on a Mac, and export from the desktop DevTools.