Convert curl and Postman artifacts to k6

If you already have API test artifacts, conversion is often faster than rewriting by hand. This milestone uses QuickPizza for a concrete curl example you can paste without secrets.

To convert existing artifacts, complete these steps.

  1. In k6 Script Authoring mode, paste one or more curl commands, or attach a Postman collection JSON file.

  2. For a minimal QuickPizza smoke request, you can paste a command like this one.

    Bash
    curl -sS -o /dev/null -w "%{http_code}" https://quickpizza.grafana.com/

    Then enter a conversion prompt. For example, paste a prompt like this one.

    Convert this curl command to a k6 script with a 200 check and sleep(1) between iterations.

  3. For Postman, use your own collection, or attach a small export that calls QuickPizza. Ask explicitly using a prompt like one of these.

    • Convert this Postman collection to k6 and preserve collection variables as k6 __ENV or script constants where safe.
  4. Optional: If you also have an OpenAPI or Swagger spec for the same API, attach or paste it with your curl or Postman input so paths, parameters, bodies, and checks can align with the spec. Refer to Use k6 Script Authoring mode and Enrich with an OpenAPI spec.

  5. Review how your input was mapped to k6. Check each of these areas.

    • URLs and methods
    • Headers and authentication
    • Request bodies and variables
    • Checks and thresholds
  6. After you receive k6 code, open the k6 script editor with a prompt such as “Open the k6 script editor” so you can keep editing and running in the Performance app without starting from a local file. Select the k6 project that should hold the test. Refer to Open the k6 script editor in the mode overview and to Use the script editor for Create and Create and Run.

  7. If you prefer a local smoke test, copy the script into a file such as quickpizza-from-curl.js, then run this command.

    Bash
    k6 run --iterations 1 quickpizza-from-curl.js
  8. Resolve // TODO: comments and placeholder env vars before you point the script at a non-demo host.

Note

You can use prompts like the following examples.

  • Convert these curl commands to a k6 script with checks and thresholds.
  • Convert this Postman collection to k6 and preserve request variables.

Paste your curl or attach your collection in the same chat message after the prompt so conversion has full context.

You now know how to convert artifacts into a k6 draft, continue in the Cloud script editor, or optionally verify with a local smoke run. In the next milestone, you improve an existing script for quality and reliability.


page 5 of 9