HAR to k6 Converter
Open a HAR file recorded in your browser’s DevTools and get a k6 load test script — with static assets and trackers filtered out, redirects and cookies handled the way k6 handles them, and tokens replaced by environment variables.
Everything runs locally: your HAR file never leaves your browser.
Convert a HAR file to a k6 script
Kept 4 of 11 requests. Skipped: 4 static assets, 1 analytics and trackers, 1 CORS preflights, 1 redirects k6 follows itself.
What happened to the example
The recording has eleven requests and the script sends four. The stylesheet, script, image
and font are static assets; the Google Analytics hit is a tracker; the OPTIONS request is a
CORS preflight the browser sent on its own; and /account/ is the second hop of
a 302 that k6 will follow by itself — so the check on /account expects the
final 200, not the 302. The session cookie and HTTP/2 :authority header are
gone, the bearer token became __ENV.AUTH_TOKEN, the password became
__ENV.PASSWORD, and the 2.6-second pause while the login form was filled in is
kept as sleep(2.6).
Convert a HAR file to a k6 script: the steps
To convert a HAR file to a k6 script, record the journey in DevTools with
“Preserve log” on, export it as HAR (with sensitive data, if the flow needs a login), and
open it here. Untick domains you do not own, check the script, then run it with the
environment variables listed on its first line:
k6 run -e AUTH_TOKEN=… -e PASSWORD=… script.js. Start with 1 VU to confirm
every check passes before raising the load.
A Grafana har-to-k6 alternative that runs in the browser
If you are looking for a Grafana har-to-k6 alternative because you cannot install Node.js or Docker on the machine you are working on, this runs in any browser tab, works offline once loaded, and keeps the recording on your machine. The output is a plain k6 script with no dependencies beyond k6 itself.
Generate a k6 script from HAR, then make it realistic
A script generated from a HAR replays one user’s exact session. To
generate a k6 script from HAR that behaves like many users, replace the
values that should differ per user — search terms, product IDs, IDs returned by an earlier
response — with data from a SharedArray or values read from the previous
response, and use scenarios in options to shape the load over time.