Paste a curl command and get JavaScript fetch, Python requests, Node axios and Go net/http.
A curl converter reads a curl command and writes the same HTTP request as code, here in four languages at once: JavaScript fetch, Python requests, Node.js axios and Go net/http. The command is split into words the way a shell would split it, the options are read, and one request is built from them: a method, a URL, headers, an optional body and optional credentials. The page sample, curl -X POST with an Authorization header, a Content-Type of application/json and a JSON body, becomes a POST to the same URL with the same two headers and the body as an exact string. Nothing is executed and no request is made. The page only turns text into text.
-X and --request set the method. -H and --header add a header. -d, --data, --data-raw and --data-binary set the body, and several are joined with &. --data-urlencode percent-encodes its value. --json sets the body and adds the JSON Content-Type and Accept headers. -u and --user give Basic auth. -F and --form build a multipart form, and a value starting with @ is a file. -G moves the data into the query string. -b adds cookies, -A the User-Agent, -e the Referer. -k, -L, --compressed, --url and -I or --head are read as well. Quoting follows the shell: single quotes, double quotes, backslash escapes, $'...' strings, a backslash at the end of a line, and the ^ used by the Windows command prompt. Only the first command is converted.
A body from -d is sent exactly as written, and curl adds Content-Type application/x-www-form-urlencoded unless you set one, so the page adds that header too and says so. With -F the library sets the multipart Content-Type and its boundary, so any Content-Type you passed is left out. Files named with @ are not read by this page. In fetch they become a placeholder with a TODO comment; in Python, axios and Go the code opens the file by its path. A value written name=<file is a text field filled from the file, not an upload. -b cookies become a Cookie header in fetch, axios and Go, but browsers forbid setting Cookie from fetch, so a comment says it works in Node.js only. fetch cannot send a body with GET or HEAD, so for those the body is left out of the fetch code with a comment and a notice. In Python, -I together with -L adds allow_redirects=True, because requests.head does not follow redirects by default. Non-ASCII Basic auth logins are encoded to UTF-8 before Base64, as curl does. The fetch code cannot skip certificate checks for -k, so it has a comment instead. curl stops at a redirect unless you pass -L, but all four libraries follow redirects, so turn on Do not follow redirects unless -L is used to match curl. Shell variables such as $TOKEN are left as written.
Options that change the request but have no simple equivalent, such as --max-time, --proxy, --cert, --retry and -T, are listed in a notice by name so you can add them yourself. Options that only affect curl's own output, such as -s, -v, -i and -o, are skipped without a notice. A command longer than 2,000 words or 100,000 characters is not read. Python, axios and Go code is meant to run as written; the fetch code runs in a browser or in Node.js 18 or later, and the axios code needs the axios package and Node.js 18 or later for FormData. Tokens and passwords in your command appear in the generated code, so replace them before you share it. The command is processed in this tab.
Paste the command and copy the JavaScript fetch box. For curl -X POST https://api.example.com/v1/users -d 'a=1' you get a fetch call with method POST, the form Content-Type header and body 'a=1'.
curl sends Content-Type application/x-www-form-urlencoded with -d when you set none. The page copies that so the converted request behaves the same. If you pass your own Content-Type, for example application/json, yours is used and nothing is added.
A value such as -F 'file=@report.pdf' becomes a multipart form. Python, axios and Go open report.pdf by that path, and fetch gets an empty Blob with a TODO comment because a browser cannot read files by path. The file itself is never read by this page.
Yes, whether it was copied in bash style with single quotes and $'...' strings, or in Windows cmd style with the ^ character. Every header in it is kept, so remove the ones you do not need before you use the code.
fetch has no setting to skip certificate checks, so the code carries a comment about NODE_TLS_REJECT_UNAUTHORIZED. Python gets verify=False, axios gets an https agent with rejectUnauthorized false, and Go gets InsecureSkipVerify. Use it for testing only.
No. The text is processed in your browser and not uploaded, and nothing is run or fetched. The command is never saved; only the redirect option is kept on this device.