curl to Python, fetch and Go code
- Free
- No sign-up
- No upload
- Works offline
Tool facts
- Price
- Free, no sign-up, no watermark
- Are files uploaded?
- No. Everything is processed in this browser, on your device.
- Offline use
- Works without a connection once this page has loaded
- Browser
- A recent Chrome, Edge, Firefox or Safari, on computer or phone.
Check it yourself: press F12, open the Network tab, then use the tool. No request carries your data.
About curl to Code
curl to Code turns a curl command into equivalent JavaScript fetch, Python requests or Go net/http code as you type. It reads both formats that the Chrome, Edge and Firefox developer tools produce with Copy as cURL: bash, with single quotes, $'…' strings and backslash line breaks, and Windows cmd, with ^" quoting and ^ line breaks. A summary shows the method and why curl picks it, the URL and its query parameters, how many headers are kept, the body type, auth, cookies and every option that was not converted.
The conversion follows curl's own rules: data makes the request a POST unless -G moves it into the query string, several -d values are joined with &, --data-urlencode encodes the way curl does, and a user name and password in the URL become basic auth. JSON bodies become objects (JSON.stringify in fetch, json= in Python), form bodies become URLSearchParams or a dict, and -F becomes FormData, files= or a multipart writer. Because curl does not follow redirects without -L, the generated code turns redirects off too. The request itself is never sent.
curl to Code runs entirely in your browser. Your data is processed on your device and is never uploaded to Qiyi or anyone else.
How to use curl to Code
- In your browser's developer tools, open the Network tab, right-click a request and choose Copy as cURL (bash) or Copy as cURL (cmd).
- Paste it into the curl command box. Sample (bash) and Sample (cmd) load the same copied Chrome request in each format.
- Pick fetch, Python or Go above the generated code.
- Leave Remove browser-only headers on to drop sec-ch-ua, sec-fetch-* and similar headers, or turn it off to keep every header.
- Read the notes under Parsed for anything that was not converted, then press Copy.
Frequently asked questions
Is my request sent or uploaded anywhere?
No. The command is split into words and converted by JavaScript in this page, and the tool makes no network request at all. Keep in mind that tokens, passwords and cookies from the command are copied into the generated code, so do not post that code in public.
Which curl options are converted?
-X, -H (including Name; for an empty value), -d, --data-raw, --data-binary, --data-urlencode, --json, -F and --form-string, -u, -b with a cookie string, -A, -e, -G, -I, -L, -k, --compressed, -m, --connect-timeout, --url, --url-query and --oauth2-bearer. Options that only change curl's own output, such as -s, -o, -v and -i, are listed as ignored. Anything else, for example --cert, -x or -T, is listed under Notes as not converted instead of being dropped silently.
Why can the cmd version of a request give a different body than the bash version?
Chrome's cmd escaping writes a line break as ^ followed by an empty line, so CR LF becomes LF, and it leaves backslashes that are not in front of a quote doubled when cmd.exe and curl.exe read them back. The tool reads the command the way cmd.exe and curl.exe do, so the code sends what curl would send, not what the browser sent.
Why does the Python code have allow_redirects=False and no Content-Type header?
curl only follows redirects with -L, while requests follows them by default, so the flag keeps the behaviour the same. When the body is JSON, it is passed as json=, and requests then adds Content-Type: application/json itself, so a plain application/json header is left out. The query string is moved into params, as a list of tuples when a key repeats.
Does the fetch code run in a browser?
It runs in browsers and in Node.js 18 or later as an ES module, because it uses top-level await. Browsers silently drop forbidden headers such as Cookie, Origin and Referer, cannot skip certificate checks for -k, and return an opaque response when redirects are turned off; the code says so in comments. Code that reads local files for -d @file or -F file=@path runs in Node.js only.