SoftwareTestPilot
Performance TestingPublished: 8 min read

cURL to k6 Load Test — Convert a Real Request into a Performance Suite

Turn a single cURL into a full k6 load test: thresholds, checks, ramping VUs, and CI-friendly output. Includes a free cURL → k6 converter.

Avinash K
Founder & QA Engineer at SoftwareTestPilot
Share:XLinkedInWhatsApp
cURL to k6 load test conversion example
cURL to k6 load test conversion example

2026-07-17 · By Avinash K

The fastest path from "I want to load-test this endpoint" to "here is a passing k6 script running in CI" is capture a real cURL, convert to k6, add thresholds. Here is the full workflow.

Step 1 — capture cURL from DevTools

Open the target request in Chrome DevTools → Network → right-click → Copy → Copy as cURL. Paste into the cURL → Code Converter and pick "k6" as the target.

Step 2 — the generated k6 script

import http from 'k6/http';
import { check, sleep } from 'k6';

export const options = {
  vus: 20,
  duration: '2m',
  thresholds: {
    http_req_failed: ['rate<0.01'],
    http_req_duration: ['p(95)<800'],
  },
};

export default function () {
  const res = http.post('https://api.example.com/orders',
    JSON.stringify({ productId: 42, qty: 2 }),
    { headers: { 'Content-Type': 'application/json',
                 'Authorization': `Bearer ${__ENV.API_TOKEN}` } });
  check(res, { 'status is 201': (r) => r.status === 201 });
  sleep(1);
}

Step 3 — ramping VUs for realistic traffic

export const options = {
  stages: [
    { duration: '30s', target: 10 },
    { duration: '2m',  target: 50 },
    { duration: '30s', target: 0 },
  ],
};

Step 4 — export results

k6 run --out json=result.json script.js
k6 run --out influxdb=http://localhost:8086/k6 script.js

Step 5 — gate in CI

k6 exits non-zero when thresholds fail. Add it as a GitHub Actions step and PR checks fail automatically when p95 regresses.

Frequently asked questions

1.Does k6 support GraphQL?
Yes — it's just a POST with a JSON body. The converter handles the payload verbatim.
2.How many VUs can a single k6 machine run?
Rule of thumb: 300–1,000 VUs per modest cloud VM. Beyond that use k6 Cloud or distributed mode.
3.Should I randomise data?
Yes — use k6/data or the free /tools/random-test-data-generator to seed a CSV, then iterate with SharedArray.
4.Can I convert an entire Postman collection?
Yes — use the /tools/postman-to-code converter with target 'k6'.