cURL to Code Converter
Paste a curl command, for example one copied from your browser's DevTools with Copy as cURL, and get equivalent code for JavaScript fetch, Axios, Python requests, Node.js, PHP and Go. Headers, JSON and form bodies, file uploads, cookies and basic auth are all converted.
How to use the cURL to Code Converter
- Copy a curl command: in Chrome, Edge or Firefox DevTools open the Network tab, right-click a request and choose Copy as cURL, or take one from API documentation.
- Paste it into the box. Multi-line commands with
\or^continuations are fine. - Pick a language tab: fetch, Axios, Python, Node.js, PHP or Go. The code updates instantly.
- Check the summary of method, URL, headers and body, and read any warnings about unsupported options.
- Copy or download the generated code and drop it into your project.
How curl options map to code
| curl | Meaning | Python requests | JavaScript fetch |
|---|---|---|---|
-X PUT | HTTP method | requests.put(...) | method: "PUT" |
-H 'Name: value' | Request header | headers={...} | headers: {...} |
-d 'a=1&b=2' | Form body, implies POST and application/x-www-form-urlencoded | data='a=1&b=2' | body: "a=1&b=2" |
--json '{...}' | JSON body plus JSON Content-Type and Accept headers | json={...} | body: JSON.stringify({...}) |
-F '[email protected]' | Multipart form upload | files={...} | body: formData |
-G -d 'q=x' | Send data as a query string with GET | appended to the URL | appended to the URL |
-u user:pass | HTTP basic authentication | auth=('user', 'pass') | Authorization: Basic … |
-b 'k=v' | Send cookies | cookies={...} | Cookie header |
-L | Follow redirects | default behaviour | default behaviour |
-k | Skip TLS certificate verification | verify=False | not possible in fetch |
-m 10 | Maximum time in seconds | timeout=10 | signal: AbortSignal.timeout(10000) |
Shell quoting rules the parser understands
- Single quotes
'...'keep everything literally; this is what browsers use for “Copy as cURL (bash)”. - Double quotes
"..."allow\",\\,\$and\`escapes. Shell variables like$TOKENare kept as literal text, so replace them with real values or environment lookups in your code. - ANSI-C strings
$'...'decode\n,\t,\',\xHHand\uHHHH. Chrome uses them when a body contains special characters. - Line continuations: a trailing
\(bash, zsh, macOS) or^(Windows cmd) joins lines. Windows cmd escapes such as^"are also removed.
Tips for production code
Commands copied from a browser often include dozens of headers (sec-ch-ua, sec-fetch-*, accept-language) that the server does not need. Try removing them one by one; usually only Authorization, Content-Type and maybe a cookie matter. Move tokens and cookies into environment variables, add error handling for non-2xx status codes, and set a timeout so a slow server cannot hang your program.
Frequently asked questions
How do I copy a request as curl from my browser?
Open DevTools (F12), go to the Network tab, reload the page, right-click the request and choose Copy > Copy as cURL (bash). On Windows, Chrome also offers Copy as cURL (cmd); this converter understands both formats.
Which curl options are supported?
The common ones: -X/--request, -H/--header, -d/--data, --data-raw, --data-binary, --data-urlencode, --json, -F/--form, -G/--get, -u/--user, -b/--cookie, -A/--user-agent, -e/--referer, -I/--head, -L/--location, -k/--insecure, --compressed, -m/--max-time and --url. Options without an equivalent, such as proxies or output files, are listed as warnings.
Why does my -d request become a POST?
That is how curl behaves: sending data with -d or -F makes curl use POST and, for -d, the Content-Type application/x-www-form-urlencoded unless you set another one. Use -G to send the data as a query string with GET, or -X to force a method.
Is it safe to paste commands with tokens or cookies?
The conversion happens entirely in your browser with JavaScript; nothing is sent to a server. Still, generated code will contain the same secrets, so move tokens into environment variables before committing code.
Why can't fetch in the browser send my Cookie header?
Browsers treat Cookie, User-Agent (in some browsers), Host and a few other headers as forbidden for fetch and silently drop them. The generated code is correct for Node.js 18+ and other server-side runtimes; in a browser, use credentials: 'include' and let the browser send its own cookies.
Does it handle file uploads?
Yes. -F '[email protected]' becomes FormData in JavaScript, a files dict in Python, CURLFile in PHP and a multipart writer in Go. Because the file lives on your computer, the code references the same path.