HAR to k6 Script
Paste a HAR file from your browser developer tools and get a k6 script with one request per entry, headers, request bodies and a status check for each.
Use the tool
Why this tool exists
The quickest way to write a realistic load test is to record what a browser does and replay it. The recording is a HAR file, but k6 wants JavaScript, so each entry must become an http call with the right method, URL, headers and body.
This tool does that conversion. It drops headers that a client sets itself, such as Host, Cookie and User-Agent, can skip images, CSS, fonts and scripts, and adds a check that the status matches what was recorded. You choose virtual users, duration and think time. Real tests need more: dynamic values like tokens and ids must be extracted and reused, and cookies need care. Treat the output as a base to edit.
How to use it
- Export a HAR file from the browser network tab and paste its JSON.
- Set virtual users, duration (or leave empty for one iteration) and sleep time.
- Copy the script into a file and run it with k6 run.
Frequently asked questions
Are cookies and auth tokens kept?
Cookie headers are removed, and other headers such as Authorization are kept as recorded. Tokens will expire, so replace them with a login step or an environment variable.
Why are static files skipped?
Load tests normally target the API or page endpoints. Images, fonts, CSS and scripts are skipped by default, and you can untick the option to include them.
Does the script handle redirects or parameter correlation?
Redirects are followed by k6 by default, but dynamic values are not extracted. You must add correlation, such as reading a CSRF token from a response, yourself.
Is the HAR uploaded?
No. It is read in your browser. HAR files often hold cookies and tokens, so share the converted script only after removing sensitive values.