cURL to Code Converter
Convert a curl command to fetch, Axios, Python, Go, PHP and more. Runs in your browser.
About this curl to code converter
This tool turns a curl command into working code for JavaScript fetch, Axios, Python requests, Node.js, Go, PHP and wget. It is for developers who found a request in API docs or in the browser's Network tab and need the same call inside their own program.
Paste the command and pick a language. The parser understands the options people actually copy: -X, -H, -d and the other --data forms, --json, -F uploads, -u, -b, -L, -k, --compressed, quoted strings and backslash line breaks. Commands copied from Chrome or Edge as cURL (cmd) for Windows work too, caret escapes and all.
The command often holds a bearer token or a session cookie, so it never leaves this page and is never stored in the URL. When the code would behave differently from curl, a note says how. Need to test the response? Paste it into the JSON formatter.
Features
Seven targets
Browser fetch, Axios, Python requests, Node.js with the built-in https module, Go net/http, PHP's cURL extension and a GNU wget command.
JSON bodies as real objects
When the body is JSON, the code shows it as an object: JSON.stringify({...}) in JavaScript, json= with a Python dict, and a readable raw string in Go.
Forms and uploads
-d pairs become a dict in Python. -F fields become FormData, a multipart writer in Go, CURLFile in PHP and files= in requests, with the file path kept.
Auth, cookies and TLS
-u becomes each library's basic auth option. -b becomes a Cookie header or a cookies dict. -k turns into the matching skip-verify setting, with a warning comment.
Honest notes
You are told when curl and the library differ: redirects, the Cookie header in browsers, wget lacking multipart, files that must be read from disk, and options that have no equivalent.
A preview of the request
Before you copy, see the method, URL, headers and body type curl would send, with the password masked, so you can spot a missing header early.
How to use the curl to code converter
- 1Paste a curl command, for example from your browser's Copy as cURL.
- 2Choose the language you want: fetch, Axios, Python, Node, Go, PHP or wget.
- 3Read the notes on anything that differs from curl, then copy the code.
When to use it
Reproducing a browser request in a script
In DevTools, right-click a request, choose Copy as cURL, paste it here and pick Python. You get a requests call with the same headers and cookies.
Turning API docs into client code
Most API references show curl. Convert the example to Axios or Go and adjust the values instead of translating flags by hand.
Debugging a webhook
Write the call as curl once, then generate fetch for the frontend and Node for the server, so both send exactly the same headers.
Writing a cron job without curl
Some minimal containers have wget but not curl. Generate the wget version with --method, --header and --body-data, then check the schedule that runs it.
What do the common curl options mean?
These are the flags this converter reads, with the behavior the curl manual gives them:
- -X or --request sets the method word. It does not change anything else curl does.
- -H or --header adds a header. "Name:" with nothing after it removes a header curl would send by default.
- -d or --data sends a POST body as application/x-www-form-urlencoded. Several -d values are joined with &.
- --data-raw is the same as -d but treats @ as a normal character. --data-binary sends the bytes exactly as given.
- --data-urlencode percent-encodes the value part, so name=a b becomes name=a%20b.
- --json (curl 7.82.0 and later) sends the data and sets both Content-Type and Accept to application/json.
- -F or --form sends multipart/form-data. name=@file attaches a file; name=<file inlines its text.
- -u user:password sends HTTP Basic auth. -b sets cookies. -L follows redirects. -k skips TLS certificate checks. -G moves the -d data into the query string and sends a GET.
Why does my converted request behave differently?
Redirects are the usual cause. curl stops at a 301 or 302 unless you pass -L, but fetch, Axios, requests, Go's http.Client and wget all follow redirects by default. Turn on Match curl redirects to get code that stops the way curl does.
Cookies are the second. A browser will not let fetch set the Cookie header, because cookies belong to the browser's own jar. The same fetch code works in Node.js 18 and later, Deno and Bun.
Compression is the third. --compressed asks the server for gzip and makes curl unpack it. Most libraries do that already, so the option is dropped for them and kept for PHP and wget, which need it spelled out.
Converting curl to Python requests
requests is the most common target, so it gets the most care. Headers become a headers dict. A JSON body becomes json=json_data, and the Content-Type header is dropped because requests sets it for you. Form pairs become a data dict. Uploads become files= with open(path, "rb").
A typical result for a JSON POST looks like requests.post(url, headers=headers, json=json_data). -u becomes auth=(user, password), -k becomes verify=False and -m becomes timeout=.
Why use Mavros
| Mavros | Typical upload sites | |
|---|---|---|
| Your command and tokens | Stay in your browser, never in the URL | Sent to a server for conversion |
| Windows cmd input | Caret escapes understood | Bash only |
| Redirect behavior | Explained, with an option to match curl | Silently different |
| Multipart uploads | FormData, multipart writer, CURLFile, files= | Often dropped |
| Warnings | Notes for each option that changes meaning | None |
Tips
- Copy as cURL (bash) gives cleaner input than the cmd version on Windows, though both work here.
- Strip tokens and cookies before you paste generated code into a ticket or a chat. The pill above the notes lists what it found.
- Got a 401, 415 or 422 back? Look it up in the HTTP status code list. A wrong Content-Type is a common cause of 415.
- A Basic auth header is just Base64 of user:password. Decode one with the Base64 tool to see which account a command uses.
- Query strings with spaces or symbols need encoding. Build them with the URL encoder and paste the result into the command.
Questions
How do I convert a curl command to Python?
Paste the command and choose Python requests. Headers, JSON bodies, forms, files, auth and cookies are mapped to the matching requests arguments, ready to copy.
How do I convert curl to JavaScript fetch?
Choose JavaScript fetch. You get await fetch(url, { method, headers, body }). A JSON body is written as JSON.stringify of an object, and basic auth becomes an Authorization header.
Can I paste Copy as cURL from Chrome DevTools?
Yes. Both the bash and cmd versions work. Chrome adds many headers, such as sec-ch-ua; delete the ones your API does not need to keep the code short.
What is the difference between -d, --data-raw and --data-binary?
-d strips line breaks from files and treats @ as "read this file". --data-raw sends the text as typed, @ included. --data-binary sends bytes exactly, newlines kept.
Does it support file uploads with -F?
Yes. name=@path becomes a file field in every target except wget, which cannot send multipart. The code points at the same path, so check it exists where the code runs.
Why does fetch ignore my Cookie header?
Browsers block scripts from setting Cookie, because cookies are managed by the browser itself. Run the code in Node.js, or rely on the browser's own cookies with credentials: "include".
What happens to options it does not support?
They are listed in a note, for example --retry or --cacert. The rest of the command still converts, so you only need to add those few by hand.
Is my curl command sent anywhere?
No. Parsing and code generation run in this tab. The command is not saved and not added to the page address, so tokens in it stay on your device.