Generate a HAR file in Chrome (Safely)
A HAR file is a JSON archive of your browser’s HTTP requests and responses. It’s the fastest way to turn a real user workflow into a runnable API Flow in DevTools.
Follow these steps to avoid empty files, missing bodies, or noisy domains.
What a HAR contains (and why to be careful)
HAR files can include:
- URLs, methods, headers, bodies
- Responses, cookies, timing data
This can contain secrets and personal data. Use a test account and a safe environment; only capture what you need.
Before you start
- Use a staging environment or a throwaway account
- Close unrelated tabs (reduce noise)
- Need request bodies? Enable “HAR with sensitive data” and export “with content” (steps below)
Record the HAR in Chrome
Open Chrome DevTools → Network
- Right click → Inspect
- Open the Network panel
Enable export with sensitive data (if you need bodies)
- Network toolbar → gear icon
- Preferences → Network → Allow to generate HAR with sensitive data
Capture the workflow
- Check Preserve log (keeps requests across navigation)
- Optional: Disable cache
- Click the clear icon to start clean
- Perform the workflow (login, click, submit, etc.)
Export the HAR with content
- Toolbar download icon → Export HAR (with sensitive data)
- Or right‑click request list → Save all as HAR with content
Suggested names: login-create-order.har, checkout-flow.har
Sanity check your HAR
Open the file and confirm:
- File size isn’t 0 bytes
- Includes
logandentries
If it’s empty or missing bodies, re‑export with content/sensitive data enabled.
Import into DevTools Studio
Import the HAR
- Open DevTools Studio → Import → HAR File
- Select your
.har
Filter and map domains
Remove analytics/fonts/CDNs; map domains to variables (e.g., BASE_URL).
Turn traffic into a reusable test
Review flow + dependencies
Check the generated sequence and auto‑detected variable chaining.
Replace secrets with env vars
Use environment variables like {{#env:API_TOKEN}} and {{#env:LOGIN_PASSWORD}}.
Export YAML and commit
Run once locally, then export to YAML and commit to your repo.
Troubleshooting
My HAR is empty / missing request bodies
- Enable “Allow to generate HAR with sensitive data”
- Export via “Save all as HAR with content”
My HAR has 1000+ requests
- Clear the log before recording; close other tabs
- Filter domains during import
No dependencies were detected
- Detection is strongest when responses are JSON and values are reused later
- For opaque tokens, map a variable once manually
Next steps
- Importing HAR files (full guide): /docs/how-to/import-har/
- Flows overview: /flows/