Curl ⇄ YAML Conversion
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
auth:
type: bearer
token: TOKEN
body:
json:
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/usersBatch 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
body:
json:
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.json + infers POST |
-d 'key=val&key2=val2' | body.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
auth:
type: basic
username: sk_test_key
password: ""
body:
form: amount=2000¤cy=usd&source=tok_visaLoss 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 --http2-prior-knowledge https://api.example.com"# Warning: Flag --compressed has no YAML equivalent; curl handles decompression natively
# Warning: Unsupported curl flag: --http2-prior-knowledge
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) |
| Flag | Description |
|---|---|
-o, --output <file> | Write output to file |
--pretty | Pretty-print output (default) |
--loss-report | Include warnings for unsupported features (default) |
--debug | Show token stream, AST, and IR |
Best Practices
Recommended
-o to save and immediately run converted YAML