Skip to content

Tools/cURL → Code

cURL → Code

Paste a cURL command and get fetch, Axios, Python requests, and Go http. Nothing is uploaded.

Loading tool…

How to use cURL → Code

  1. 1. Copy cURL from your tools. Browser DevTools, Postman, and many API docs can copy a request as cURL. Paste the full command.
  2. 2. Review parsed fields. Confirm method, URL, headers, and body. Quoted multiline commands with backslash continuations are supported.
  3. 3. Pick a target language. Switch between fetch, Axios, Python requests, and Go. JSON bodies become native objects where possible.
  4. 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. Translating `-H` flags and `--data` bodies into `fetch` or `requests` is tedious and easy to get wrong (especially quoting). This converter tokenizes a command in the browser and emits idiomatic snippets for JavaScript, Python, and Go.

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.

Bodies, JSON, and content types

If the body parses as JSON, fetch snippets use `JSON.stringify`, Axios gets a JS object, and Python uses the `json=` argument so `requests` sets the content type for you. If the body is a form string, it is passed as raw data. Always check whether the original command used `--data` (which sets a default content type of `application/x-www-form-urlencoded` in cURL) versus `--json`. Mismatched content types are a frequent 415/400 cause when porting examples.

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"]`) 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.

Code examples

DevTools

Chrome: Network → request → Copy → Copy as cURL

fetch

const res = await fetch(url, { method: "POST", headers, body: JSON.stringify(payload) });

requests

r = requests.post(url, headers=headers, json=payload)
r.raise_for_status()

Frequently asked questions

Related tools

All tools