Import cURL, HAR, Postman or OpenAPI to a k6 Test

Import an existing request into a k6 test

You do not need to write a k6 script by hand to get started. If you already have a request captured as a cURL command, a HAR file, a Postman collection or an OpenAPI spec, LoadFocus can convert it into a runnable k6 script and attach it to your test in one step.

The conversion runs entirely in your browser. Nothing is sent to our servers during the conversion, and the generated script is attached to the test exactly as if you had uploaded it yourself.

Import panel on the New k6 Test page

Where to find it

Open the New k6 Test page (you need to be logged in) and, in step 1 Your test script, click Import from cURL, HAR, Postman or OpenAPI under the upload area (next to No script yet?) to open the import panel.

Supported formats

  • cURL: paste a curl command, for example one copied from your browser's network tab ("Copy as cURL").
  • HAR: an HTTP Archive exported from your browser's developer tools. Static assets (images, CSS, fonts) are filtered out so the test focuses on real API calls.
  • Postman: a Postman collection exported as JSON. Collection variables are resolved where possible.
  • OpenAPI: an OpenAPI or Swagger specification. Request bodies are synthesized from the schema when no example is provided.

Step by step

  1. Choose the format in the Format selector.
  2. Provide the source. Paste the cURL command or file content into the text area (5 MB at most), or pick a HAR, Postman or OpenAPI file under or upload a file:. Picking a file starts the import at once. The format is guessed from the file name (.har, a name with postman or openapi/swagger in it, collection.json, .yaml or .yml); if your file name does not match, set Format first.
  3. Decide how to handle detected auth values. The Include detected auth values in the script checkbox is on by default.
    • On (recommended for cloud runs): detected Authorization, Cookie and API-key headers are written into the script as-is, so the test works on the first run.
    • Off: those values become __ENV placeholders that you fill in yourself. Cloud runs do not set these placeholder values, so the test would fail authentication until you provide them.
  4. Click Import. LoadFocus generates a k6 script, attaches it to the test as a .js file, and fills in a test name based on the request host if you have not set one. If you upload a file, the import runs automatically.
  5. Review the generated script. Expand Preview generated script to see the k6 code, with buttons to Copy it or Download it.
  6. Configure the load and save. Set your virtual users, duration, ramp-up and load distribution as usual, then run or save the test. See How to Run a New k6 Load Test for the full configuration walkthrough.

Notes

  • Importing again replaces the previously imported script. Files you uploaded manually are left untouched.
  • If you paste a finished k6 script instead of a cURL command, the panel offers Use this as my k6 script, which attaches it as it is without converting.
  • The generated options block (virtual users, duration) is a local-run default. In the cloud the values you set in step 2 How much load? take precedence.
  • Prefer to work outside the app? The same conversion is available as free public tools: cURL to k6, HAR to k6, Postman to k6 and OpenAPI to k6.