ZeroBloatTools LogoZeroBloatTools
Verified Preset100% Client-Side
Updated 2026-11-15•Instant Calculation

cURL to Grafana k6 Load Test Script Converter

Pre-loaded in Grafana k6 output mode so REST cURL commands compile immediately to idiomatic `k6/http` load test scripts with `check()` assertions and `__ENV` secrets.

Interactive Pre-Configured Simulator
cURL Compiler Studio
Client-Side AST
Samples:
POST/v1/orders•3 headers
Raw cURL Input
AST Request InspectorParsed Cleanly
POSThttps://api.example.com/v1/orders
Query Params
1
Headers
3
Payload
JSON
Auto-masked 1 secret headers: Authorization → env vars
test.k6.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import http from 'k6/http';
import { check, sleep } from 'k6';
export const options = {
vus: 10,
duration: '30s',
thresholds: {
http_req_failed: ['rate<0.01'],
http_req_duration: ['p(95)<500'],
},
};
export default function () {
const url = "https://api.example.com/v1/orders?notify=true";
const payload = JSON.stringify({
"customerId": "cus_109",
"items": [
{
"sku": "PRO-PLAN",
"qty": 2
}
],
"currency": "USD"
});
const params = {
headers: {
"Authorization": `Bearer ${__ENV.API_BEARER_TOKEN ?? ''}`,
"Content-Type": "application/json",
"X-Request-ID": "req_42",
},
};
const res = http.request('POST', url, payload, params);
check(res, {
'status is 2xx': (r) => r.status >= 200 && r.status < 300,
'response time < 500ms': (r) => r.timings.duration < 500,
});
sleep(1);
}
Terminal Execution:
k6 run --vus 10 --duration 30s test.k6.js
Request Translation Reference

Grafana k6 Output Structure & CLI Execution Cheat Sheet

Maps cURL payloads and environment tokens cleanly into Grafana k6 Goja runtime modules.

k6 ElementGenerated Code PatternCLI / Runtime FlagPurposeNotes
k6/http Clienthttp.post(url, JSON.stringify(body))params.headersGoja ES ModuleZero Node.js dependencies; native high-concurrency VUs
__ENV Injection`Bearer ${__ENV.API_BEARER_TOKEN || ''}`k6 run -e API_BEARER_TOKEN=...Secret SafeKeep production bearer tokens outside load test git repos
Validation & Pacingcheck(res, { status 2xx })sleep(1)--vus 10 --duration 30sPrevents synthetic tight loops from overwhelming test runners
Playwright APIRequestContext Patterns

Header Normalization, Auth & Payload Mapping

  • Unlike Playwright (`process.env`), Grafana k6 runs on Goja JavaScript and exposes runtime variables through `__ENV.*`—handled automatically in k6 mode.
  • Automatically serializes JSON bodies via `JSON.stringify(...)` as required by `k6/http` `http.post()`.
  • Includes `check(res, ...)` assertions and `sleep(1)` pacing out of the box so generated scripts run immediately with `k6 run`.
Common cURL Conversion Bugs

Critical Errors to Avoid

Common Error: Leaving browser-specific sec-ch-ua and sec-fetch-* headers in automated API tests.
Best Practice: Browser headers like sec-ch-ua-mobile or sec-fetch-dest indicate browser state and change across browser versions. In headless CI test runs, leaving them in can trigger Cloudflare, Datadog, or AWS WAF anti-bot blocks due to header mismatch. Always strip browser-only headers from backend API tests.
Common Error: Hardcoding production Bearer tokens or API keys into git-committed test files.
Best Practice: Avoid committing raw credentials. Keep secret masking enabled to replace Authorization tokens with environment variables (process.env.API_BEARER_TOKEN), and supply the real secret via your .env file or GitHub Actions secrets.
Common Error: Using page.goto() instead of Playwright APIRequestContext for REST testing.
Best Practice: Testing backend APIs by navigating a full browser page adds massive CPU and memory overhead (rendering HTML, parsing CSS, running client JS). Use Playwright's built-in request fixture (APIRequestContext), which executes direct HTTP requests at Node.js network speeds without launching a browser window.
Frequently Asked Questions

Convert cURL to Grafana k6 Load Test Script Questions Answered

How do I pass environment secrets into the generated k6 script?

Pass `-e API_BEARER_TOKEN="your_token"` on the CLI (`k6 run -e API_BEARER_TOKEN="xyz" --vus 10 --duration 30s generated-load-test.k6.js`).

Why does k6 use JSON.stringify() while Playwright passes an object?

Playwright’s `APIRequestContext` serializes plain objects passed to `data` automatically, whereas k6’s `http.post(url, body, params)` expects a serialized string payload when sending JSON.

Common cURL Flags Cheat Sheet

-X, --request:
HTTP Method (GET, POST, PUT, DELETE, PATCH, HEAD)
-H, --header:
Request Header ("Header-Name: value")
-d, --data, --data-raw:
HTTP Request Body / Payload (JSON, Form-UrlEncoded, Text)
-u, --user:
Basic Authentication ("username:password")
-b, --cookie:
HTTP Cookie header ("name=value; session=123")
-k, --insecure:
Allow insecure SSL/TLS connections during local testing
Security & Credential Hygiene

Security & Client-Side Privacy Notice

100% Client-Side Processing: This utility parses and generates code entirely in your local browser using an in-memory AST tokenizer. Your cURL commands, secret tokens, endpoints, and data payloads are never sent to any external server.
Environment Secret Hygiene: Always keep "Mask Auth Tokens" checked before pasting curl commands with production credentials. Never commit raw Bearer tokens, cookies, or private API keys to git repositories.