Skip to main content
Free plan, no cardStart free
Exports · checked against the code 2026-11-10

k6 export: a load profile leaves as a script you can run yourself

On the load screen, Export as k6 script saves a JavaScript file that sends the same targets with the same weights, virtual users, ramp-up, duration and wait between requests; an attached data set is saved beside it as data.csv. The script is written in your browser, so nothing is sent anywhere to produce it.

Which way the data flows

A script file leaves the platform; nothing comes back in.

Set it up

  1. Open Performance Testing and set up the profile: targets, virtual users, ramp-up, duration and think time, and a CSV data set if each virtual user should send different data.
  2. Under Export and import, choose Export as k6 script. If a data set is attached, also choose Save the data set as data.csv and keep the two files in one folder.
  3. Run it where you like with k6 run and the file name. The same section saves the profile as a JSON file that the load screen reads back.

What the exported script looks like

This is the script the load screen writes for a profile of two targets (a product page and a cart call), 20 virtual users over two minutes with a 30-second ramp, one to three seconds of think time and a data set of 50 rows. It is generated by the same code that writes your export, and a test fails the build if the two ever differ.

checkout-smoke.k6.js (with data.csv beside it)

// Load profile "Checkout smoke" exported from Dokimore on 2026-11-10T12:00:00.000Z.
// Run it with k6 (https://k6.io):  k6 run <this file>
// It holds every header and body as typed, including any token: keep it as carefully as that credential.
// It reads ./data.csv (50 rows; columns: sku, account), saved beside this script.
import http from 'k6/http';
import { sleep } from 'k6';
import exec from 'k6/execution';
import { SharedArray } from 'k6/data';

export const options = {
  stages: [
    { duration: '30s', target: 20 },
    { duration: '90s', target: 20 },
  ],
};

const TARGETS = [
  {
    "name": "target-1",
    "method": "GET",
    "url": "https://shop.example.com/products?sku=${sku}",
    "headers": {
      "Accept": "application/json"
    },
    "body": null,
    "weight": 3
  },
  {
    "name": "target-2",
    "method": "POST",
    "url": "https://shop.example.com/api/cart",
    "headers": {
      "Content-Type": "application/json",
      "X-Account": "${account}"
    },
    "body": "{\"sku\":\"${sku}\",\"qty\":1}",
    "weight": 1
  }
];
const TOTAL_WEIGHT = TARGETS.reduce((sum, target) => sum + target.weight, 0);
const THINK_SECONDS = { min: 1, max: 3 };

// One copy of the rows is shared, read-only, by every virtual user.
const ROWS = new SharedArray('rows', function () {
  return parseCsv(open('./data.csv'));
});

// RFC 4180: quoted values may contain the separator, a line break, or a doubled quote.
function parseCsv(text) {
  if (text.charCodeAt(0) === 0xfeff) text = text.slice(1);
  const records = [];
  let cells = [], cell = '', quoted = false;
  for (let i = 0; i < text.length; i++) {
    const ch = text[i];
    if (quoted) {
      if (ch === '"') { if (text[i + 1] === '"') { cell += '"'; i++; } else { quoted = false; } } else { cell += ch; }
    } else if (ch === '"' && cell === '') { quoted = true;
    } else if (ch === ',') { cells.push(cell); cell = '';
    } else if (ch === '\n' || ch === '\r') {
      if (ch === '\r' && text[i + 1] === '\n') i++;
      cells.push(cell); if (!(cells.length === 1 && cells[0] === '')) records.push(cells); cells = []; cell = '';
    } else { cell += ch; }
  }
  if (cell !== '' || cells.length > 0) { cells.push(cell); records.push(cells); }
  const header = records.shift() || [];
  return records.map(function (values) {
    const row = {};
    header.forEach(function (name, c) { row[name] = values[c] === undefined ? '' : values[c]; });
    return row;
  });
}

// ${column} is replaced from the row; a name that is not a column is sent as written.
function fill(template, row, encode) {
  if (!row || template.indexOf('${') === -1) return template;
  return template.replace(/\$\{([A-Za-z0-9_.-]{1,64})\}/g, function (whole, key) {
    if (!Object.prototype.hasOwnProperty.call(row, key)) return whole;
    return encode ? encodeURIComponent(row[key]) : row[key];
  });
}

function pickTarget() {
  let x = Math.random() * TOTAL_WEIGHT;
  for (const target of TARGETS) { x -= target.weight; if (x < 0) return target; }
  return TARGETS[TARGETS.length - 1];
}

export default function () {
  const row = ROWS.length > 0 ? ROWS[((exec.vu.idInTest - 1) + exec.vu.iterationInScenario) % ROWS.length] : null;
  const target = pickTarget();
  const headers = {};
  for (const name of Object.keys(target.headers)) headers[name] = fill(target.headers[name], row, false).replace(/[\r\n]/g, '');
  const body = target.body === null ? null : fill(target.body, row, false);
  http.request(target.method, fill(target.url, row, true), body, { headers: headers, tags: { name: target.name }, redirects: 0, timeout: '30s' });
  if (THINK_SECONDS.max > 0) sleep(THINK_SECONDS.min + Math.random() * (THINK_SECONDS.max - THINK_SECONDS.min));
}

What it does not contain, stated plainly: no thresholds, checks or scenarios, because the export carries the HTTP profile only; add them in k6. The data rows are not embedded: the script reads data.csv, which the screen saves beside it, and every header and body is written as typed, including any token.

Where it stops

Stated plainly

  • The script carries the HTTP profile only: assertions, thresholds and scenarios are not written into it, so add checks and thresholds in k6 yourself.
  • k6 only: there is no JMX, Locust or Gatling export, and no JMX import.
  • The generated script was run with k6 0.55 before release; it uses k6/http, k6/execution and SharedArray.

Questions buyers ask

Is load testing on the Free plan?

No. Load tests start on Solo Pro, with up to 100 virtual users per test; Team allows 250.

Why k6 and not JMX?

k6 scripts are text that diffs and reviews like code. A JMX export was never built, and this page says so rather than implying it.

Can I turn a browser recording into a k6 script?

Not yet. A load plan built from a recording, a collection or a plain-language description runs on the platform and has no export; the k6 export covers a profile set up by hand on the load screen: targets, users, ramp, duration, think time and data set. We say so rather than imply a conversion we do not ship.

Where it is implemented

The files in our code that carry this integration. A catalogue test checks that each still exists, so this page cannot outlive the feature.

  • frontend/src/modules/performance-testing/utils/load-profile-export.ts
  • frontend/src/modules/performance-testing/components/LoadPortabilityBar.tsx

Try it against your own pipeline

Free plan, no card; the integrations on this page are on every plan.

Try it against your own app.

Record one flow and get four kinds of evidence back. Judge the results yourself.

  • Free plan, no card
  • 14-day Solo Pro trial
  • Demo replies within one business day
  • Data hosted in India