novair Back to HAR Viewer
HAR ViewerHAR files

How to sanitize a HAR file

Support asks for a HAR file; the file holds your session. Here is what a capture gives away, what the browser's sanitized export removes and what it leaves, and how to clean the rest without uploading anything.

What a HAR file gives away

A HAR file records every request exactly as it was sent and received. Whoever reads it gets what the browser had: the session cookie, the Authorization header, the tokens the server returned, and whatever you typed into a form during the capture, password included.

Our test file has 4 requests and 13 secrets: 4 cookies, 1 Authorization header, 2 sensitive parameters (a password in a form body and an access_token in a URL), 2 sensitive JSON fields (access_token and refresh_token in a response), 2 JWT, 1 GitHub token in a custom header and 1 AWS key in an HTML body.

What the browser's sanitized export removes

Recent versions of Chrome and Edge DevTools export a sanitized HAR that leaves out cookies and Authorization headers. That is the same scope as HAR Viewer's free copy. Tokens placed anywhere else stay in the file: in the URL, in a form field, in a JSON response, in a header with an in-house name.

Where                                  Free copy        Full sanitize (Pro)
Authorization, Cookie, Set-Cookie      [REDACTED]       [REDACTED]
Form body password=pa55w0rd            kept             password=%5BREDACTED%5D
JSON response access_token             kept             "[REDACTED]"
URL ?access_token=eyJ…                 kept             ?access_token=%5BREDACTED%5D
Header X-Debug: token ghp_…            kept             token replaced
HTML body: e-mail address, AWS key     kept             both replaced
Result                                 5 redacted,      12 redacted,
                                       8 secrets left   no known secret left

Sanitize it in VS Code

  1. Export the HAR from the Network panel and open it in VS Code: it opens in HAR Viewer as a table.
  2. Read the count at the top: how many secrets the file holds, by kind. Tick “Only requests with secrets” to see where they are.
  3. Run “Save a sanitized copy (cookies and auth headers)”: cookies and authentication headers become [REDACTED] in a new .sanitized.har copy; the original is not modified.
  4. Read the message that follows: it says how many secrets are still in URLs and bodies. The full sanitize (Pro) removes them too.
  5. Open the copy and look at it before you attach it to the ticket.

In-house tokens: custom rules

Detection covers known formats. A tenant ID, a session header with a custom name or an internal reference number is not known to any tool: add it to the harViewer.customRules setting (Pro), as a header name, a parameter, a JSON key or a regular expression.

"harViewer.customRules": [
  { "type": "header", "pattern": "X-Tenant" },
  { "type": "param", "pattern": "session_key" },
  { "type": "jsonKey", "pattern": "customer_ref" },
  { "type": "regex", "pattern": "ACME-[0-9]{8}" }
]

A rule with an empty pattern, an unknown type or a regular expression that does not compile is ignored, and the extension says so: “3 custom rule(s) ignored (empty, unknown type or invalid regex). Check the harViewer.customRules setting.” The other rules still apply.

Check before you send

  • Search the copy for your e-mail address, your user ID and the name of your company.
  • Search for eyJ: most JWT start that way.
  • If a token was in the file, consider it seen by everyone who had the raw file, and revoke it.
  • Never paste a raw HAR into an online sanitizer: to clean it, the site has to receive it first.

Frequently asked questions

Does Chrome sanitize HAR files automatically?

Recent Chrome versions export without cookies and Authorization headers unless you allow sensitive data in the DevTools settings. Tokens in URLs, form fields, custom headers and bodies are still exported.

Is it safe to send a HAR file to support?

Once sanitized and checked, yes: support needs the URLs, statuses, timings and error bodies, not your session. Send the raw file to nobody, and revoke any token you find in it afterwards.

Does a HAR file contain passwords?

If you logged in during the capture, yes: the form body is recorded as sent. On our test file, the free copy keeps password=pa55w0rd and the full sanitize replaces it with [REDACTED].

Check your own HAR file the same way

HAR Viewer & Sanitizer for VS Code opens your capture as a request table, counts every secret it holds and writes a copy without cookies and authentication headers, on your machine. Free, no account; Pro also clears URLs, form fields and bodies, applies your own rules, sanitizes whole folders, compares two captures and writes a ticket report.