k6 · Locust · JMeter · Artillery

HAR to Load Test Script

Turn a HAR recording into a load-test script. Pick the hosts and request types, let tokens and ids that one response hands to a later request become variables, and keep cookies and credentials out of the script. The script is only shown and downloaded, never run.

HAR file

Drop a .har file

Saved from the browser network tab, up to 60.0 MB

A HAR holds every cookie and token of the recorded session. This page reads it in your browser and the generated script leaves them out unless you choose otherwise.

HAR to Load Test Script

Operator: Abdulla Al Fahad. How tools are built and checked

A HAR file records everything a browser did, which makes it a good source for a load test and a bad thing to paste into one: it holds the session cookie, the bearer token and the password typed into the login form. Converting it by copying request after request produces a script that replays one person's session and leaks it.

This page turns a recording into a k6, Locust, JMeter or Artillery script in three steps that a hand conversion usually skips. It keeps only the hosts and request types you pick. It spots values that the server hands out and a later request sends back, such as a token or an order id, and makes them variables. And it removes cookies and credentials before any text is written.

The script is shown and downloaded as text. The page never sends a request, and it does not run the script.

Key features

  • Filters by host and by resource type (documents, XHR and fetch, scripts, stylesheets, images, fonts, media), with redirects, OPTIONS preflights and optionally failed requests skipped
  • Correlation: a value in a JSON response that the client did not send earlier and a later request sends back becomes a variable, extracted after the response and substituted in the URL, headers and body
  • Credentials mode: strip (the default), replace with environment variables, or keep as recorded behind a confirmation tick. Cookie and Referer headers are dropped, and anything that looks like a secret is removed by name or by value shape
  • Output as k6 JavaScript, a Locust file, a JMeter test plan with an HTTP Cookie Manager, or an Artillery scenario, each with a status check per request and a pause between requests taken from the recorded gaps

How a HAR entry becomes a request and how correlation works

A HAR is JSON with log.entries, one per request, each holding the request (method, URL, headers, postData), the response (status and content with a mimeType and text, possibly base64) and a start time and duration. The page keeps http and https entries, orders them by start time, reads the resource type from the browser's _resourceType field (falling back to the MIME type or file extension), and leaves out headers that the HTTP stack sets itself, such as Host, Content-Length, Accept-Encoding and the sec-* family. Cookie headers are removed in strip and environment modes because every tool keeps its own cookie jar; JMeter's plan includes a Cookie Manager for that reason.

How it works

Each request is split into tokens (path segments, query values, header values, JSON strings and form values). A response's JSON leaves become candidates when they are strings of at least six characters that contain a digit or run to 20 characters or more, or whole numbers of five digits or more, and when no earlier request had already sent that token. A candidate that appears in a later request is turned into a variable named after its JSON key, such as corr_token or corr_id.

Authorization and similar headers are kept in strip mode when, after correlation, they are made only of a prefix such as Bearer and a variable. The recorded secret is gone, and the header still works because the script gets the token from the login response at run time.

Secrets elsewhere are masked: query parameters named like token, key, signature or password, and JSON or form body fields named like password, secret, token, access key or signature, get the value REDACTED. Header names ending in key or signature, or containing token, secret, session, credential, subscription or password, are treated as credentials. Values are also tested by shape wherever they sit: a JWT, a Bearer, Token or Basic value, or a key with a well-known prefix (such as sk_live_, ghp_ or AKIA) is removed even from an innocently named header, parameter or field, and JSON stored inside a string or inside a form field is masked the same way. Referer is dropped because it often repeats the page URL with its query string.

Recorded text is made inert in the generated file. In JMeter, every string property of every element is compiled for ${...} functions, so each ${ in a header name, host name, path or JSON key is written as ${__char(36)}{ and reads back as the two characters. In Artillery, a literal {{ is written as { { (a note at the top of the file says how many were changed), because Artillery would evaluate it as a template expression. k6 and Locust get quoted string literals with ${ and backticks escaped.

Budgets: HAR files up to 60 MB, 20,000 entries read, 2,000 requests in a script, bodies up to 200,000 characters, and 50,000 correlation candidates.

Common use cases

  • A QA lead records a 12-step checkout in Chrome and needs a Locust file by the afternoon; she ticks the shop host, leaves images and scripts out, and gets a file with the cart id and order id as variables.
  • A performance engineer converts one HAR to both k6 and JMeter to compare two tools against the same journey, and downloads each from its own tab.
  • A developer on a regulated project sets credentials to environment variables, so the committed script reads AUTHORIZATION from the CI secret store.
  • A team recording a single-page app keeps only XHR and fetch on the API host, which cuts 300 asset requests down to the 40 calls that matter.
  • An engineer checks the Correlated values table and finds that a CSRF token was not detected because it comes from an HTML form, so she adds the extraction by hand in the generated k6 file.

How to use this tool

  1. In the browser's network tab choose Save all as HAR, and drop the file here, or choose Load example.
  2. Tick the hosts and request types to include. Only the busiest host is ticked at first; third-party hosts are usually noise.
  3. Choose how to treat credentials and think time, then choose the tool tab. Set users and duration where the tool takes them in the file.
  4. Check the Correlated values table: each row says which response and path a variable is read from and where it is used.
  5. Copy or download the script, read it, and point it at an environment you may load test.

Example

shop-checkout.har: login, product list, order create and order read

POST /api/login (password in the body, token in the response)
GET /api/products?page=1 with Authorization: Bearer <token>
POST /api/orders with the SKU from the product list in the body
GET /api/orders/ord_7f3a91c2e8 using the id from the previous response
each request carries Cookie: sid=...; theme=dark

Requests, correlations and removed secrets with credentials stripped

4 requests, 3 correlated values: corr_token (response path token), corr_sku (items[0].sku), corr_id (order.id)
4 Cookie headers dropped, 1 body field masked (password becomes REDACTED)
3 Authorization headers kept, rebuilt as Bearer plus corr_token
pauses of 1.2 s, 2.6 s and 1.2 s taken from the recorded gaps

Tips for best results

  • Set the longest pause to 5 or 10 seconds. A recording often contains a coffee break, and an unbounded gap turns into a very slow virtual user.
  • Rename the variables to something meaningful before sharing; the page names them after the JSON key, so two ids become corr_id and corr_id_2.
  • Run the generated script once with a single user against a test environment before raising the load.

Edge cases to watch

Only JSON responses are searched for correlation. Values in HTML, headers such as Location, or Set-Cookie are not extracted, and a login that relies on them will need manual work.

Requests that overlapped in the browser are replayed one after another, so a page that loaded 20 calls in parallel becomes a sequence, and its response time under load is not comparable.

Stripping cannot see a secret inside a URL path, such as /reset/<token>. There is no name to match, so the page warns when a path holds a long opaque segment and leaves the URL as recorded; read the URLs before sharing the script.

A value that happens to repeat can be turned into a variable by mistake, for example a product id that appears in two unrelated calls. The table shows every substitution so it can be reviewed.

Common errors and how to fix them

This JSON has no log.entries list, so it is not a HAR file.
Save the network panel with Save all as HAR. A Postman collection or a curl history is a different format.
No request matches the current filters.
Tick another host or request type. The first host ticked is the busiest one, which may be an analytics domain.

Best practices

  • Keep credentials on strip or environment, and treat a script made with keep as a secret file, since it holds working tokens and cookies.
  • Review the generated script as code: a load test sends real traffic, so confirm the hosts it targets are ones you are allowed to test.

Frequently asked questions

Why does the script have no cookies when my app needs a session?

Each tool keeps a cookie jar and stores the Set-Cookie from the login response itself, so a replayed login creates a fresh session. Copying the recorded cookie would reuse one stale session for every virtual user.

How is this different from the HAR file analyzer?

That page reads a HAR to find slow or failed requests and to redact it. This one produces a script from it. The credential removal here happens before generation, so the HAR is never rewritten.

What happens to a request with a body over 200,000 characters?

It stays in the script without its body, and a warning names the request, because a very large payload is better supplied from a file at run time than embedded in the script.

Can it correlate values that appear in the URL path?

Yes. If a response returns an id such as ord_7f3a91c2e8 and the next request calls /api/orders/ord_7f3a91c2e8, the path becomes /api/orders/ followed by the variable.