Curl ⇄ YAML Conversion
Convert curl commands to curl-runner YAML and back. Paste a curl command, get clean YAML. Convert YAML specs to canonical curl commands.
Feature overview →Bidirectional conversion between raw curl commands and curl-runner YAML specs.
Overview
The convert command provides a deterministic, loss-aware conversion engine between curl commands and curl-runner YAML. Paste a curl command from documentation or browser DevTools, get a clean YAML spec. Convert YAML specs back to canonical curl commands.
- Bidirectional: curl → YAML and YAML → curl
- Batch Scripts: Convert entire shell scripts at once
- Loss-Aware: Warns about unsupported features
Curl to YAML
Convert a raw curl command into a clean, human-editable curl-runner YAML spec. The converter automatically detects JSON bodies, authentication, query parameters, and more.
# Convert a curl command to YAML
curl-runner convert curl "curl -X POST https://api.example.com/users \
-H 'Authorization: Bearer TOKEN' \
-H 'Content-Type: application/json' \
-d '{\"name\":\"Alex\",\"role\":\"admin\"}'"request:
method: POST
url: https://api.example.com/users
headers:
Content-Type: application/json
auth:
type: bearer
token: TOKEN
body:
name: Alex
role: adminYAML to Curl
Convert a curl-runner YAML file back to canonical, shell-safe curl commands. Useful for sharing commands with teammates or debugging.
# Convert a YAML file back to curl
curl-runner convert yaml api-test.yamlcurl \
-X POST \
-H 'Authorization: Bearer TOKEN' \
-d '{"name":"Alex","role":"admin"}' \
-H 'Content-Type: application/json' \
https://api.example.com/usersPostman to YAML
Turn a Postman collection into curl-runner files, one per request, with a .env for the variables:
curl-runner convert postman my-api.postman_collection.jsonSee Postman Import for the output, what's converted and what needs your attention.
OpenAPI to YAML
Turn an OpenAPI or Swagger spec into curl-runner files, one per operation, with a .env for the base URL and secrets:
curl-runner convert openapi openapi.yamlSee OpenAPI Import for the output, what's converted and what needs your attention.
Batch Script Conversion
Extract and convert all curl commands from a shell script into a single YAML collection. The parser handles multiline commands, ignores non-curl lines, and strips piped output.
#!/bin/bash
# api-tests.sh
# Health check
curl https://api.example.com/health
# Create user
curl -X POST https://api.example.com/users \
-H "Content-Type: application/json" \
-d '{"name":"Alex"}'
# Get users
curl -H "Authorization: Bearer TOKEN" \
https://api.example.com/users# Convert all curl commands from a shell script
curl-runner convert file api-tests.shrequests:
- name: request_1
method: GET
url: https://api.example.com/health
- name: request_2
method: POST
url: https://api.example.com/users
headers:
Content-Type: application/json
body:
name: Alex
- name: request_3
method: GET
url: https://api.example.com/users
auth:
type: bearer
token: TOKENAutomatic Detection
The converter automatically normalizes and detects semantic intent from curl flags.
| Curl Input | YAML Output |
|---|---|
-d '{"key":"val"}' | body: {key: val} + infers POST |
-d 'key=val&key2=val2' | body: "key=val&key2=val2" with Content-Type: application/x-www-form-urlencoded |
-H 'Authorization: Bearer T' | auth.type: bearer |
-u user:pass | auth.type: basic |
-F 'file=@img.png' | formData.file.file: img.png |
URL?q=test&page=1 | params: {q: test, page: 1} |
--max-time 30 | timeout: 30000 (ms) |
-A 'MyApp/1.0' | headers.User-Agent |
Save to File
Write conversion output directly to a file with -o. The output is immediately usable by curl-runner.
# Save conversion output to a file
curl-runner convert curl "curl https://api.example.com/users" -o test.yaml
# Then run it immediately
curl-runner test.yamlReal-World Example
Convert complex real-world curl commands with authentication, form data, and more.
# Real-world: Stripe API call
curl-runner convert curl "curl -X POST https://api.stripe.com/v1/charges \
-u sk_test_key: \
-d amount=2000 \
-d currency=usd \
-d source=tok_visa"request:
method: POST
url: https://api.stripe.com/v1/charges
headers:
Content-Type: application/x-www-form-urlencoded
auth:
type: basic
username: sk_test_key
password: ""
body: "amount=2000¤cy=usd&source=tok_visa"Loss Handling
Some curl flags don't have YAML equivalents. The converter emits YAML comments and warnings so you know exactly what was lost.
# Unsupported flags produce warnings
curl-runner convert curl "curl --compressed https://api.example.com"# Warning: Flag --compressed has no YAML equivalent; curl handles decompression natively
request:
method: GET
url: https://api.example.comDebug Mode
Use --debug to inspect the full conversion pipeline: token stream, AST, and intermediate representation (IR).
# Debug mode shows the full conversion pipeline
curl-runner convert curl "curl -u admin:secret https://api.example.com" --debugDEBUG:
{
"tokens": ["curl", "-u", "admin:secret", "https://api.example.com"],
"ast": {
"url": "https://api.example.com",
"headers": [],
"user": "admin:secret",
"unsupportedFlags": []
},
"ir": {
"method": "GET",
"url": "https://api.example.com",
"headers": {},
"auth": { "type": "basic", "username": "admin", "password": "secret" },
"metadata": { "source": "curl", "warnings": [] }
}
}
request:
method: GET
url: https://api.example.com
auth:
type: basic
username: admin
password: secretCLI Reference
| Command | Description |
|---|---|
convert curl "<cmd>" | Convert inline curl command to YAML |
convert file <script.sh> | Convert shell script to YAML (batch) |
convert yaml <file.yaml> | Convert YAML to curl command(s) |
convert postman <collection.json> | Convert a Postman collection to YAML files and a .env |
convert openapi <spec.json|spec.yaml> | Convert an OpenAPI or Swagger spec to YAML files and a .env |
| Flag | Description |
|---|---|
-o, --output <file> | Write output to file. For convert postman and convert openapi, a directory |
--pretty | Pretty-print output (default) |
--loss-report | Include warnings for unsupported features (default) |
--debug | Show token stream, AST, and IR |
Best Practices
- Recommended
- Use
-oto save and immediately run converted YAML - Review warnings for any lost curl features
- Use batch conversion for migrating shell scripts
- Use debug mode to understand complex conversions
- Use
- Notes
- Shell-specific features (pipes, variables) are stripped
- Some curl flags have no YAML equivalent (see warnings)
- YAML-only features (expect, store, when) can't map to curl
- Round-trip preserves semantics, not exact syntax
YAML Validation
Validate curl-runner YAML configuration files against the schema. Discover issues, get fix suggestions, and auto-fix common problems.
Postman Import
Import a Postman collection as curl-runner YAML, from the CLI or the studio. You get one file per request, a .env with the variables, and no secrets in files.