Skip to content
midgeDocs
HAR filesHow to remove sensitive data from a HAR file
HAR files

How to remove sensitive data from a HAR file

Sanitize a HAR file before sharing it: what to remove (cookies, tokens, passwords, personal data), how to do it by hand, and a free in-browser tool.

To sanitize a HAR file, replace the values of anything that grants access or identifies a person before you share it: Cookie and Set-Cookie headers, Authorization and API key headers, tokens in URLs, passwords and tokens in request bodies, and personal or payment data in responses. You can do this by hand in a text editor or with jq, or drop the file into the free HAR sanitizer, which does it in your browser without uploading anything and gives you a .sanitized.har file to share.

This matters because a HAR file is close to a full transcript of your session. With a valid session cookie or bearer token from it, someone can often act as you without knowing your password. Support teams ask for HAR files every day, and most of them are attached to tickets, emails and chat threads that many people can read.

What to remove, and why

Where it appearsExampleWhy it is sensitive
Cookie request header and cookies arrayssession_id=s%3A9f2c...A session cookie can let anyone use your signed-in session
Set-Cookie response headerrefresh=...; HttpOnlyNew or refreshed session cookies
Authorization headerBearer eyJhbGciOi...Bearer tokens and Basic credentials
Custom credential headersX-API-Key, X-Auth-Token, X-CSRF-TokenAPI keys and anti-forgery tokens
URL query strings?access_token=..., ?code=..., ?signature=...OAuth codes, magic links, signed download URLs
Request bodies (postData)"password": "...", "cardNumber": "..."Anything typed into forms while recording
Response bodies (content.text)"refresh_token": "...", customer recordsTokens returned by APIs, personal data
Redirect URLsLocation: /callback?code=...Codes passed during sign-in

Personal data deserves the same care as secrets. A response listing customers, a profile endpoint returning an address, or an order history can all end up in a HAR file. If you work under privacy rules such as GDPR, sharing that file may count as sharing personal data.

What browsers already remove

Recent versions of Chrome and Edge export a “sanitized” HAR by default. It leaves out Cookie, Set-Cookie and Authorization headers. To include them you have to turn on Allow to generate HAR with sensitive data in DevTools settings and choose the “with sensitive data” export.

That is a good default, but it only covers those three headers. Tokens in URLs, custom headers, request bodies and response bodies are still in the file. Firefox and Safari do not describe any sanitizing in their documentation, so treat their exports as complete. In all four browsers, the file needs a second pass before you share it widely.

Option 1: Use the HAR sanitizer

The HAR sanitizer is the fastest way to clean a file:

  1. Open the sanitizer and choose your .har file, or drop it on the page. It is read in your browser; nothing is uploaded.
  2. Optionally, add field names that are private in your app, separated by commas, such as customerRef, internalNotes.
  3. Read the summary. It shows how many headers, cookies, URL parameters, body fields, JWTs, card numbers, API keys and other items were redacted.
  4. Click Download sanitized HAR to save a .sanitized.har copy. Your original file is not changed.

What it checks, using the same open rules as the Midge extension:

  • Authorization, Proxy-Authorization, Cookie, Set-Cookie, X-API-Key, X-Auth-Token, X-CSRF-Token and X-XSRF-Token headers, plus any header whose name contains token, secret, key, session, auth, signature or password.
  • Sensitive URL parameters such as token, access_token, refresh_token, code, api_key, signature, password and session, in request URLs, redirect URLs and page titles.
  • Password, token, secret, OTP, PIN, card, IBAN and SSN fields in JSON, form-encoded and multipart bodies, including nested objects. Text bodies stored as base64 are decoded, cleaned and re-encoded.
  • Values that look like secrets wherever they appear: JWTs, card numbers that pass the Luhn check, private key blocks and known API key formats from providers such as Stripe, AWS, GitHub, Slack, Google, OpenAI and Anthropic.
  • Emails and international phone numbers are half-masked, like j***@acme.com, so the recipient can still tell which account is involved.

Redacted values become [REDACTED], so the structure of the file stays valid and the request is still easy to read.

Option 2: Clean it by hand

If you prefer not to use a tool, or need to check a file someone else cleaned, you can do it manually. HAR files are JSON, so any text editor works for small files.

  1. Make a copy of the file and work on the copy.
  2. Search for these strings, case-insensitive: authorization, cookie, token, secret, password, apikey, api_key, session, bearer, eyJ (the start of most JWTs).
  3. Replace each value, not the name, with a placeholder like REDACTED. Keep the quotes so the JSON stays valid.
  4. Check postData.text and content.text carefully. Request and response bodies are stored as escaped JSON strings, so a password might appear as \"password\":\"hunter2\".
  5. Watch for bodies marked "encoding": "base64". A text search will not find secrets inside them. Decode, clean, and re-encode, or remove the body text.
  6. Validate the JSON when you are done, for example by opening the file in the HAR viewer. If it does not load, a quote or comma was lost.

For larger files, jq is more reliable than find-and-replace. This removes the most common credentials and clears cookie arrays:

bash
jq '
  .log.entries |= map(
    .request.headers |= map(
      if (.name | test("^(authorization|cookie|x-api-key|x-auth-token)$"; "i"))
      then .value = "REDACTED" else . end)
    | .response.headers |= map(
      if (.name | test("^set-cookie$"; "i")) then .value = "REDACTED" else . end)
    | .request.cookies |= map(.value = "REDACTED")
    | .response.cookies |= map(.value = "REDACTED")
  )' session.har > session.clean.har

This script does not touch URLs, bodies or custom fields. Extend it for your app, or run the result through the sanitizer as a second check.

What sanitizing cannot fix

No rule-based tool can know everything that is private in your app. Keep these limits in mind:

  • Unusual names. A secret stored in a field called x7 will not be recognized. Add your app’s field names to the sanitizer.
  • Personal data that is not an email or phone number. Names, addresses and free-text notes in API responses stay readable. If a response is full of customer records and not needed for the bug, remove that entry’s response body entirely.
  • Random-looking strings. IDs and hashes are left alone on purpose, because they are often what the developer needs to trace the request.
  • Binary content. Images, PDFs and other binary responses are not scanned.

Before and after you share

  • Share the sanitized file only with the team that asked for it, through their support channel or ticket, not in a public forum or issue tracker.
  • If a team specifically needs the unsanitized file to debug a cookie or sign-in problem, send it privately and sign out of the app afterward. In most apps that ends the session, so the cookie in the file stops working.
  • If you find a long-lived API key in a file you already shared, rotate the key.
  • Delete local copies you no longer need.

Avoid the problem for everyday bug reports

For bugs reported inside your own team, you often do not need a HAR file at all. Midge, a free Chrome extension, records your screen or takes a screenshot and attaches console logs and network requests automatically, with the same redaction rules as the sanitizer applied before upload. Passwords, card numbers, tokens and cookies are redacted in your browser before anything leaves your device. Typed text is never recorded. Like any rule-based approach, it can miss a secret with an unusual format, which is why teams can add their own field and header names. The full list of rules is on our security page.

Official documentation

What Chrome and Edge leave out of a sanitized export was checked against their documentation on November 10, 2026. Browser behavior can change between versions.

Frequently asked questions

What should I remove from a HAR file before sharing it?

Cookie and Set-Cookie headers, Authorization and other credential headers, tokens in URLs, passwords and tokens in request bodies, and any personal or payment data in responses. Those are the parts that can let someone act as you or expose customer data.

Doesn't Chrome already sanitize HAR files?

Recent versions of Chrome and Edge export without Cookie, Set-Cookie and Authorization headers by default. Tokens in URLs, request bodies, custom headers and response bodies are still included, so the file needs another pass.

Will sanitizing break the HAR file for debugging?

Usually not. Replacing secret values with a placeholder keeps URLs, status codes, timings and the structure intact, which is what most debugging needs. If a team is investigating a cookie problem, they may need the original file through a secure channel.

Can a sanitizer miss something?

Yes. Rule-based sanitizers look for known names and formats, so a secret with an unusual name can slip through. Add your own field names and look through the result before sharing.

Is the Midge HAR sanitizer uploading my file?

No. It runs in your browser with the same redaction rules the Midge extension uses, and nothing is sent to a server.