k6 Load Test Script Generator
Turn endpoints, executors, thresholds and checks into a ready-to-run k6 script.
Test plan
2 requests · 1 scenariosHeaders 1
Query 1
Checks
Headers 2
Query 2
Checks
Generated k6 script
41 lines · 1,117 chars · 40 linesDetails
The k6 Script Generator compiles a structured test plan into an ES-module k6 script: request methods, URLs, headers, query parameters, JSON or form bodies, per-request tags and groups, status/body/response-time checks, executor scenarios (ramping-vus, constant-vus, constant-arrival-rate, ramping-arrival-rate and iteration executors), thresholds with tag selectors and abortOnFail, optional __ENV.BASE_URL templating, sleep pacing, handleSummary and a CSV-data note. Validation flags invalid URLs, malformed JSON, incompatible threshold aggregations and missing arrival-rate fields before you copy the script. Paste a curl command to import a request. Everything runs in your browser tab; the generated file runs on your own machine with k6.
More examples
Ramping API smoke test
GET https://api.example.com/users (group: Users, check: status 200)
POST https://api.example.com/users JSON {"name":"Ada"}
Executor: ramping-vus 10s → 5 VUs, 20s → 10 VUs
Threshold: http_req_duration p(95)<300Emits options.scenarios with stages, a Users group wrapping both requests, an application/json Content-Type header, status checks and a p(95) latency gate.
Open-model spike
Executor: constant-arrival-rate · rate 20 · timeUnit 1s
preAllocatedVUs 20 · maxVUs 100 · duration 1m
Threshold: http_req_failed rate<0.01 abortOnFailIncludes the duration k6 requires for arrival-rate executors and emits abortOnFail as a threshold object so CI can gate on failures.
curl import
curl -X POST https://api.example.com/orders -H 'Content-Type: application/json' -d '{"id":1}'The lite curl importer fills a POST row with the header and JSON body, then the emitter adds a default status check and metric tag.
Examples
Ramping smoke test
GET /users · ramping-vus 10s→5, 20s→10 · p(95)<300export const options = { scenarios: { smoke: { executor: 'ramping-vus', stages: [ … ] } }, thresholds: { 'http_req_duration': ['p(95)<300'] } };The whole options preamble is generated from the form model.
JSON POST with a check
POST /users · body {"name":"Ada"}const payload = { "name": "Ada" };
const res = http.post(`${__ENV.BASE_URL}/users`, JSON.stringify(payload), { headers: { 'Content-Type': 'application/json' }, tags: { name: 'POST /users' } });JSON bodies are pretty-printed as object literals and sent with the header k6 does not add automatically.
curl import
curl -X POST https://api.example.com/orders -H 'Content-Type: application/json' -d '{"id":1}'POST https://api.example.com/orders · 1 header · JSON body · status 200 checkThe importer handles -X, -H, -d/--data*, --json, -G, -F, -u and backslash continuations.
About this tool
The k6 Script Generator turns a described API test plan into a ready-to-run k6 JavaScript file. Edit a structured plan — requests, scenarios, thresholds and checks — and the output pane compiles it into an ES-module script with export const options, grouped requests, check() calls, metric tags and a default function.
The emitter supports ramping-vus, constant-vus, constant-arrival-rate, ramping-arrival-rate and iteration executors. Each scenario keeps its explicit startTime, so concurrent and staggered profiles are both expressible. Threshold selectors, aggregation compatibility and abortOnFail are validated before emission instead of failing at runtime.
Request bodies are emitted correctly: JSON bodies get an application/json header and JSON.stringify(), form bodies become urlencoded objects, and raw strings are left alone with a warning when no Content-Type is set. A lite curl importer fills request rows from commands you already have. The compiler is pure string work in your browser tab — no endpoint is contacted and no script is executed here.
What this tool does not do
- This tool generates source only; it does not execute load tests or contact your endpoints.
- The curl importer covers common flags, not the entire curl grammar; review imported rows.
- Scripts target k6 v0.50+ ES-module syntax; older versions may need adjustments.
- Threshold selectors are restricted to simple key:value tags with safe characters.
- Plans are not persisted or shareable by URL, by design — header values may contain secrets.
How to use this tool
Describe requests
Add rows with method, URL, headers, query parameters and a JSON, form or raw body. Assign a group and a metric tag where useful.
Add checks
For each request choose status equals, body contains or response time below N ms. Labels appear as keys inside check().
Choose an executor
Pick ramping-vus stages, constant-vus, an arrival-rate profile or an iteration executor. Give each scenario a name and startTime.
Set thresholds
Pair a metric with an aggregation k6 supports for it — p(95) for latencies, rate for checks and failures — and add abortOnFail for CI gating.
Copy or download
Fix any validation errors shown above the output, then copy the script or download script.js and run it with k6 run script.js.
Use cases
First load test
Turn an endpoint list into a valid k6 script without looking up boilerplate.
Latency SLO gate
Emit p(95)/p(99) thresholds with abortOnFail so CI fails on a regression.
Soak and spike profiles
Switch executors from constant-vus to arrival-rate while keeping the same request flow.
Internal API smoke
Use the BASE_URL toggle so the same path list runs against staging and production.
Plan fields and what they emit
| Field | Emitted k6 syntax |
|---|---|
| ramping-vus stages | scenarios.name.stages = [{ duration, target }, …] |
| constant-arrival-rate | rate / timeUnit / preAllocatedVUs / maxVUs / duration |
| Threshold p(95)<300 | 'http_req_duration': ['p(95)<300'] |
| Tag selector | 'http_req_duration{name:GET /users}': [...] |
| Status check | check(res, { 'status is 200': (r) => r.status === 200 }) |
| JSON body | const payload = {…}; JSON.stringify(payload) + Content-Type |
| BASE_URL toggle | `${__ENV.BASE_URL}/path` + k6 run -e BASE_URL=… |
Durations use k6 syntax: 500ms, 30s, 5m or 1h.
Common mistakes
Mistake:Using a percentile aggregation on http_reqs or rate on a duration metric.
Fix:Pick an aggregation from the stat list; the editor restricts it to valid pairs and validation flags the rest.
Mistake:Forgetting duration on constant-arrival-rate.
Fix:The validator requires duration, rate, timeUnit, preAllocatedVUs and maxVUs — k6 rejects a partial open-model scenario.
Mistake:Enabling discardResponseBodies while checking response bodies.
Fix:Turn it off or remove body checks; the tool warns because those checks would always fail.
Mistake:Pasting a token-bearing header into a shared URL.
Fix:This tool never puts the plan in a share link; header values stay in the tab and are not persisted.
Mistake:Running an ESM script with a CommonJS-only syntax check.
Fix:Check generated files as .mjs or with an ES-module-aware tool; the scripts use import statements.
Frequently asked questions
What executors can it generate?
Ramping VUs, constant VUs, constant arrival rate, ramping arrival rate, per-VU iterations and shared iterations. Each scenario keeps its name and startTime so you can model staggered or concurrent traffic; invalid combinations such as a missing arrival-rate duration are flagged before you copy the script.
How do thresholds work?
You choose a metric, an aggregation, a comparison and a numeric bound. Latency metrics offer p(95), p(99), avg, min and max; checks and failed requests use rate; http_reqs uses count or rate. Add a tag key and value to target one request, and enable abortOnFail to make k6 exit non-zero when the SLO is breached.
Where does the script run?
Only on your machine. The generator compiles text in your browser tab and never contacts the endpoints you describe. Copy the script or download script.js, then run k6 run script.js (or k6 run -e BASE_URL=https://your-host script.js when the BASE_URL toggle is on).
Can I add authentication headers?
Yes. Add any header key and value to a request, including Authorization or a cookie; the emitted params object includes them. Note that this tool deliberately does not persist the plan or put it in a share link, because header values often contain tokens.
How do I parameterize CSV data?
Turn on the CSV note to include a commented import of PapaParse from the k6 jslib URL plus an example that reads a file with open(). k6 cannot resolve npm packages, so the note uses the jslib import rather than a bare npm module.
Does it send my API plan anywhere?
No. Request definitions, headers and generated code stay in the tab. There is no execution server, no upload and no network request from the tool itself.
References & standards
Related tools
.env Secret Safety Linter
Validate .env syntax and spot likely leaked credentials or placeholder secrets.
.gitattributes Generator
Build .gitattributes rules for line endings, Git LFS, GitHub linguist marks and merge drivers — with a one-line explanation for every rule.
.htaccess Generator
Build an Apache .htaccess — HTTPS redirects, rewrites, error pages, security headers, and basic auth
2D Fluid Dynamics & Particle Physics Sandbox
A physics playground with two engines sharing one canvas. The fluid mode runs a real Eulerian Navier-Stokes solver — semi-Lagrangian advection, explicit diffusion, Jacobi pressure projection and vorticity confinement — that you paint with dye and velocity using mouse or touch. The particle mode is a damped Verlet N-body engine with gravity wells, Coulomb attractors and repulsors, spring links, wall restitution and elastic circle collisions. Particle counts adapt to the device (100k target on WebGL2 desktop, 2k-5k on CPU fallback), and every configuration exports as runnable code: a Matter.js world, a PixiJS ticker setup, or a standalone vanilla Canvas engine.
A/B Test Sample Size Calculator
Compute required sample size per variant and test duration from baseline conversion rate, minimum detectable effect, alpha and power.
ABA Routing Number Validator
Validate 9-digit US ABA routing numbers with 3-7-1 Mod-10 breakdown.