Paste a curl command, get working code
This converter turns a curl command into the same HTTP request in JavaScript fetch, axios, Node.js, Python requests, Go net/http, PHP's curl extension or Rust reqwest. It reads curl the way your shell and curl itself do: single and double quotes, $'…' strings, line continuations, combined flags like -sSL, repeated -d data and multipart -F fields. Headers, cookies, basic and bearer authentication, JSON bodies, timeouts and TLS settings are carried across, and anything that cannot be translated is pointed out. The command is parsed in your browser and never sent anywhere, so tokens and cookies in it stay private.
How to convert a curl command to code
- 1Copy a request as curl. In Chrome, Edge or Firefox, open the developer tools, go to the Network tab, right-click a request and choose Copy › Copy as cURL. Both the bash and the Windows
cmdvariants work. - 2Paste the command into the left pane. Multi-line commands with
\or^continuations are fine. - 3Pick the target language: fetch, axios, Node.js, Python, Go, PHP or Rust, or JSON to see the parsed request.
- 4Read the notes under the code for flags that were ignored or need attention, then copy the code or download it as a file.
What gets converted
- Method and URL
- -X/--request, --url, -G/--get (data moved into the query string), -I/--head, -T/--upload-file (PUT). Without -X, the method is chosen the way curl chooses it: POST when there is a body, GET otherwise.
- Headers
- -H/--header, -A/--user-agent, -e/--referer, -b/--cookie and -r/--range. Repeated headers are combined.
- Bodies
- -d/--data, --data-raw, --data-binary and --data-urlencode (joined with &, as curl does), --json, and multipart -F/--form fields including file uploads with ;type= and ;filename=.
- Authentication
- -u/--user for basic auth, --digest, --oauth2-bearer, and credentials written in the URL.
- Connection options
- -k/--insecure, -L/--location, --compressed, -m/--max-time and -x/--proxy, where the target language has an equivalent.
JSON bodies become real objects
When the body is JSON, either because the Content-Type says so or because it plainly is, it is pretty-printed and, where the language allows, written as a native value: an object passed to JSON.stringify for fetch, a plain object for axios, and a dictionary passed as json= for Python requests, with true, false and null turned into True, False and None. That is much easier to edit than an escaped string. Turn off Format JSON bodies to keep the body byte for byte as it was.
Browser fetch versus Node.js
The two fetch targets differ because browsers restrict what a page may send. A script in a browser cannot set Cookie, Referer, Host, Accept-Encoding or any Sec- header, cannot skip certificate checks and cannot read files from a path. The browser target says which headers will be dropped. The Node.js target can do all of these: files are read with openAsBlob and readFile, and --insecure or a proxy become an undici dispatcher.
To check what a response status means once the request runs, see the HTTP status code reference. Query values that need escaping can be encoded with the URL encoder.
Quoting rules, handled
Most conversion errors come from quoting. In a POSIX shell, single quotes keep everything literally, double quotes still process \" and \$, and $'…' understands escapes such as \n and \x41. A backslash at the end of a line continues the command. Windows cmd uses ^ for escapes and continuations instead, which is what "Copy as cURL (cmd)" produces. The tokenizer follows each of these rules, so the body your code sends is exactly the body curl would have sent.
Anything after a pipe, a semicolon or a redirect, such as | jq ., belongs to the shell rather than to curl and is ignored, with a note.
Frequently asked questions
- Is my curl command sent to a server?
- No. The command is parsed and the code is generated in your browser. Tokens, cookies and passwords in it never leave your device.
- How do I copy a request as curl from the browser?
- Open developer tools (F12), select the Network tab, right-click the request and choose Copy, then Copy as cURL. On Windows, either the bash or the cmd version can be pasted here.
- Which curl options are supported?
- The options that define a request: method, URL, headers, cookies, every -d variant, --json, -F forms, -u authentication, -G, -I, -T, -L, -k, --compressed, --max-time and --proxy. Output options such as -s, -o and -v do not affect the request and are ignored.
- Why does the browser fetch code leave out some headers?
- Browsers forbid scripts from setting headers such as Cookie, Referer, Host and Accept-Encoding, and fetch silently drops them. Use the Node.js target if you need to send them.
- How are file uploads converted?
- A -F field like file=@photo.jpg becomes a multipart file field that reads photo.jpg from disk in Node.js, Python, Go, PHP and Rust. In browser fetch it uses a file chosen with an <input type="file">, because pages cannot read files by path.
- What does --data-urlencode do?
- It percent-encodes the value before sending it, so name=a b&c is sent as name=a%20b%26c. The converter applies the same encoding, so the generated code sends the same bytes.
- Does curl follow redirects?
- Not unless you pass -L. Most HTTP libraries follow redirects by default, so the generated code usually follows them either way; PHP's curl extension only does when -L is given.