Migrate from JMeter to k6.

Move a JMeter load test to k6: thread groups, HTTP samplers, assertions, extractors, CSV data, timers, transaction controllers, CLI runs and reports mapped to k6 options and JavaScript, with a checklist, gotchas and live numbers for both tools.

JMeter (live data): 9,611 GitHub stars. 0 GitHub releases in the last 60 days. last GitHub activity 2026-11-21

k6 (live data): 32,380 GitHub stars. 3 GitHub releases in the last 60 days, latest v1.8.3. last GitHub activity 2026-11-23

Users, ramp-up and duration: JMeter: Thread Group Number of Threads (users): 50 Ramp-up period (seconds): 30 Loop Count: Infinite Specify Thread lifetime: Duration (seconds) 300 → k6: export const options = { stages: [ { duration: '30s', target: 50 }, // ramp-up { duration: '4m30s', target: 50 }, ], }; (A VU is the k6 equivalent of a thread. The ramp-up period becomes the first stage; the total duration is the sum of the stages, so subtract the ramp.)

Fixed number of loops: JMeter: Thread Group Number of Threads (users): 5 Loop Count: 10 → k6: export const options = { scenarios: { checkout: { executor: 'per-vu-iterations', vus: 5, iterations: 10 }, }, }; (The plain iterations option is a total shared by all VUs. The per-vu-iterations executor is the one that matches Loop Count per thread.)

Requests per minute: JMeter: Constant Throughput Timer Target throughput (in samples per minute): 100 // or an Open Model Thread Group schedule: rate(1/sec) random_arrivals(2 min) rate(3/sec) → k6: export const options = { scenarios: { api: { executor: 'constant-arrival-rate', rate: 100, timeUnit: '1m', duration: '5m', preAllocatedVUs: 10, }, }, }; (constant-arrival-rate and ramping-arrival-rate are k6's open model: the rate is fixed and k6 adds VUs as needed, up to preAllocatedVUs or maxVUs.)

HTTP request with defaults: JMeter: HTTP Request Defaults Protocol: https Server Name or IP: api.example.com HTTP Request "Users" Method: GET Path: /users → k6: import http from 'k6/http'; const BASE = 'https://api.example.com'; export default function () { const res = http.get(BASE + '/users'); } (There is no defaults element; keep the base URL in a constant or read it from __ENV.)

POST with a JSON body and headers: JMeter: HTTP Header Manager Content-Type: application/json HTTP Request "Login" Method: POST Path: /login Body Data: {"email":"a@b.co","password":"secret"} → k6: const payload = JSON.stringify({ email: 'a@b.co', password: 'secret' }); const res = http.post(BASE + '/login', payload, { headers: { 'Content-Type': 'application/json' }, }); (Headers travel with each request in the params object. A Header Manager shared by many samplers becomes a params constant you pass to each call.)

Assert status and body text: JMeter: Response Assertion Field to Test: Response Code Pattern Matching Rules: Equals Patterns to Test: 200 Response Assertion Field to Test: Text Response Pattern Matching Rules: Contains Patterns to Test: Welcome → k6: import { check } from 'k6'; check(res, { 'status is 200': (r) => r.status === 200, 'body has Welcome': (r) => r.body.includes('Welcome'), }); (A failed check does not abort the run or set a failed status. To fail the test on checks, add a threshold on the checks metric (see the gotchas).)

Response time limit: JMeter: Duration Assertion Duration in Milliseconds: 500 → k6: export const options = { thresholds: { http_req_duration: ['p(95)<500'], http_req_failed: ['rate<0.01'], }, }; (JMeter fails each sample over the limit. A k6 threshold judges the aggregate (here the 95th percentile) and fails the whole run with a non-zero exit code.)

Extract a value from JSON: JMeter: JSON Extractor Names of created variables: token JSON Path expressions: $.token Match No.: 1 → k6: const token = res.json('token'); (res.json takes a selector in gjson syntax (dot paths, no leading $). Deeper values: res.json('data.items.0.id').)

Extract with a regular expression: JMeter: Regular Expression Extractor Name of created variable: csrf Regular Expression: name="csrf" value="(.+?)" Template:

$ → k6: const csrf = res.body.match(/name="csrf" value="(.+?)"/)[1]; (res.body is a string, so plain JavaScript regex does the job. res.html('input[name=csrf]') is there for HTML.)

Parameters from the command line: JMeter: User Defined Variables threads: ${__P(threads,10)} host: ${__P(host,api.example.com)} jmeter -n -t plan.jmx -Jthreads=50 -Jhost=staging.example.com → k6: const host = __ENV.HOST || 'api.example.com'; // k6 run -e HOST=staging.example.com script.js // K6_VUS=50 k6 run script.js (or --vus 50) (-e sets __ENV for the script only. k6 options come from K6_* environment variables or CLI flags, which take precedence over the options object.)

CSV test data: JMeter: CSV Data Set Config Filename: users.csv Variable Names: email,password Recycle on EOF?: True Sharing mode: All threads // then ${email} and ${password} in samplers → k6: import papaparse from 'https://jslib.k6.io/papaparse/5.1.1/index.js'; import { SharedArray } from 'k6/data'; import exec from 'k6/execution'; const users = new SharedArray('users', () => papaparse.parse(open('./users.csv'), { header: true }).data, ); export default function () { const user = users[(exec.vu.idInTest - 1) % users.length]; // user.email, user.password } (SharedArray loads the file once and shares it between VUs. Pick the row yourself: by VU id as here, or by iteration for Recycle-on-EOF behaviour.)

Think time: JMeter: Constant Timer Thread Delay (in milliseconds): 1000 Uniform Random Timer Random Delay Maximum (in milliseconds): 2000 Constant Delay Offset (in milliseconds): 1000 → k6: import { sleep } from 'k6'; import { randomIntBetween } from 'https://jslib.k6.io/k6-utils/1.2.0/index.js'; sleep(1); sleep(randomIntBetween(1, 3)); (A JMeter timer runs before every sampler in its scope. sleep runs where you put it, so place one after each request you want paced.)

Group requests as a transaction: JMeter: Transaction Controller "Checkout" Generate parent sample: checked (child samplers: Cart, Pay) → k6: import { group } from 'k6'; group('Checkout', () => { http.post(BASE + '/cart', cartBody); http.post(BASE + '/pay', payBody); }); (k6 emits group_duration for the whole block and tags every metric inside with group. Thresholds can target it: 'group_duration{group:::Checkout}': ['p(95)<2000'].)

Run something once: JMeter: setUp Thread Group (before the test) Once Only Controller (once per thread) HTTP Request "Login" → k6: export function setup() { const res = http.post(BASE + '/login', creds); return { token: res.json('token') }; // once per test } export default function (data) { if (__ITER === 0) { /* once per VU */ } http.get(BASE + '/me', { headers: { Authorization: 'Bearer ' + data.token } }); } export function teardown(data) { /* tearDown Thread Group */ } (setup runs once for the test and its return value reaches every VU. __ITER is zero on a VU's first iteration, which is the Once Only Controller case.)

Cookies: JMeter: HTTP Cookie Manager Clear cookies each iteration?: unchecked → k6: // nothing to add: each VU has its own cookie jar export const options = { noCookiesReset: true }; // keep cookies across iterations (k6 stores and sends cookies per VU on its own. It resets the jar after every iteration unless noCookiesReset is set.)

Run from the command line: JMeter: jmeter -n -t plan.jmx -l results.jtl -e -o report/ → k6: k6 run script.js k6 run --vus 10 --duration 30s script.js K6_WEB_DASHBOARD=true K6_WEB_DASHBOARD_EXPORT=report.html k6 run script.js (The last form writes a self-contained HTML report at the end of the run, the nearest thing to -e -o.)

Raw results file: JMeter: Simple Data Writer Filename: results.jtl // jmeter.save.saveservice.output_format=csv (default) → k6: k6 run --out json=results.json script.js k6 run --summary-export=summary.json script.js (--out json streams every metric sample, like a .jtl. --summary-export writes only the end-of-test aggregates, checks and thresholds.)

Percentiles in the summary: JMeter: // user.properties aggregate_rpt_pct1=90 aggregate_rpt_pct2=95 aggregate_rpt_pct3=99 → k6: export const options = { summaryTrendStats: ['avg', 'min', 'med', 'max', 'p(90)', 'p(95)', 'p(99)'], };

Distributed load: JMeter: jmeter-server # on each load generator jmeter -n -t plan.jmx -R host1,host2 -l results.jtl → k6: # Kubernetes, with the k6-operator apiVersion: k6.io/v1alpha1 kind: TestRun spec: parallelism: 4 script: configMap: { name: checkout-test, file: script.js } (JMeter runs the full plan on every server, so 1000 threads on 6 servers is 6000 threads. The operator splits one test across the pods. Try one k6 instance first; the docs cover tuning it for large tests.)

Checked against: jmeter 5.6.3, k6 2.4.0 (latest GitHub release, 2026-11-19)