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 Kamble
Founder & QA Engineer at SoftwareTestPilot
Reviewed by Priyanka G.
Share:XLinkedInWhatsApp

2026-07-17 · By Avinash Kamble, reviewed by Priyanka G.

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'.
Keep going

Practice these questions

Run a live QA mock interview tailored to this topic and get per-skill scoring in minutes.

Found this useful?
Share:XLinkedInWhatsApp

Was this article helpful?

Cluster · Performance

More from k6 Load Testing

Grafana k6 — scripting, thresholds, scenarios.

Pillar guide · 2 articles
More in this cluster
From the Performance pillar

Keep building your QA edge

Continue reading

Join the QA Community

Connect with fellow testers, share job leads, and get career advice.

Premium QA Resources

Stop Reinventing the Wheel. Upgrade Your QA Arsenal.

Take your testing skills from beginner to Lead Engineer. Supercharge your daily workflow with our premium digital resources.

  • Ready-to-use testing strategy templates
  • Advanced API & UI automation guides
  • ⏱️ Save 10+ hours a week on test planning
4.9/5 rating
Explore All Products

⭐⭐⭐⭐⭐ Trusted by 1,000+ Software Test Pilots • Instant Access