How to use cURL → Code
- 1. Copy cURL from your tools. Browser DevTools, Postman, and many API docs can copy a request as cURL. Paste the full command.
- 2. Review parsed fields. Confirm method, URL, headers, and body. Quoted multiline commands with backslash continuations are supported.
- 3. Pick a target language. Switch between Go net/http, Python requests, fetch, and Axios. JSON bodies become native objects where possible.
- 4. Paste into your app. Replace example tokens with environment variables. Do not commit live secrets from the original command.
About this tool
cURL is the lingua franca of HTTP examples. API docs, GitHub issues, and Stripe-style dashboards all speak cURL because it is copy-pasteable in a terminal. Application code usually does not — especially Go `net/http` and Python `requests`. Translating `-H` flags and `--data` bodies into idiomatic clients is tedious and easy to get wrong (especially quoting). This converter tokenizes a command in the browser and emits snippets for Go, Python, fetch, and Axios.
Before / after: cURL → Go
A typical DevTools copy becomes a `http.NewRequest` with headers and body. The tool fills method, URL, and header map; you still add timeouts and `context.Context` the way your service already does.
Before / after: cURL → Python
JSON bodies map to `requests.post(..., json=payload)` when the body parses as JSON; form bodies stay as `data=`. Always move Bearer tokens into `os.environ` before you commit.
Before / after: cURL → fetch / Axios
fetch gets `JSON.stringify` for objects; Axios prefers a plain object under `data`. Content-Type mismatches from `--data` vs `--json` are a common 415 when porting — check the generated headers.
What the parser understands
PureDevKit handles the flags you actually see in DevTools copies: `-X`/`--request`, `-H`/`--header`, `-d`/`--data`/`--data-raw`/`--data-binary`, `--json`, `-u` basic auth, `-A` user-agent, `-e` referer, `--url`, `-I` HEAD, `-G` GET, `-k`, and `--compressed`. Line continuations with `\` are folded. Single and double quotes are respected. Flags that only affect the cURL process (`-s`, `-L`, `-o`) are ignored because they are not part of the HTTP request your application sends.
Auth headers belong in env vars
Copied cURL often contains `Authorization: Bearer ...` or `-u user:password`. Those values are still in your clipboard and now in this page’s memory — locally, not on a server — but they should not land in git. Move them to environment variables (`process.env.API_TOKEN`, `os.environ["API_TOKEN"]`, `os.Getenv`) before you share the snippet. Rotate any token that was pasted into a ticket or a chat log.
What generated code will not do
The emitter does not retry, does not parse cookies into a jar, does not implement multipart file streams from `-F`, and does not verify TLS for `-k` (insecure is a cURL-only escape hatch you should not copy into production). Treat the output as a starting request, then add timeouts, error handling, and cancellation (`AbortSignal`, `context.Context`) the way your codebase already does. Need the reverse? Use Code → cURL. Building from scratch? Try HTTP Composer or Raw HTTP.
Code examples
cURL (input)
curl -sS -X POST 'https://api.example.com/v1/items' \
-H 'Authorization: Bearer TOKEN' \
-H 'Content-Type: application/json' \
--data '{"name":"demo"}'Go (output)
req, err := http.NewRequest(http.MethodPost, "https://api.example.com/v1/items", strings.NewReader(`{"name":"demo"}`))
req.Header.Set("Authorization", "Bearer "+os.Getenv("API_TOKEN"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)Python (output)
import os, requests
r = requests.post(
"https://api.example.com/v1/items",
headers={"Authorization": f"Bearer {os.environ['API_TOKEN']}"},
json={"name": "demo"},
)
r.raise_for_status()fetch (output)
const res = await fetch("https://api.example.com/v1/items", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.API_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ name: "demo" }),
});