API documentation shows requests as curl commands; your code needs them as a library call. Paste the command and the tool rewrites the same request in seven forms: fetch for the browser, fetch for Node.js (18 and later), axios, Python requests, Go net/http, PHP cURL and wget. Next to the code it lists the method, URL, headers and body it understood, and notes anything that did not carry over.
The command is never run. A small tokenizer written for this tool splits it into words the way a shell would, without expanding anything, and the parser reads the curl options from those words. Nothing is sent anywhere, which matters because pasted commands often contain tokens.
What it understands
- Quoting: single quotes, double quotes with \" escapes, ANSI-C strings like $'line\n', backslash escapes, and the classic '"'"' trick for a quote inside single quotes.
- Line continuations: \ at the end of a line (bash and zsh), ^ (Windows cmd) and the backtick (PowerShell). In cmd, \" inside double quotes is read as a quote, as curl.exe does.
- Options: -X, -H (repeated), -d, --data-raw, --data-binary, --data-urlencode, --json, -F with files and ;type=, -u, -b, -A, -e, -L, -k, -G, -I, -m, --compressed, --oauth2-bearer and --url, in short, long, combined (-sSL) and attached (-XPOST, --header=…) forms.
- Bodies: several -d values are joined with & like curl does; JSON bodies become objects in fetch, axios and Python (json=), form-encoded bodies become a dictionary in Python; -G moves the data into the query string.
Without -X, curl sends POST when there is a body and GET otherwise; -d adds a form content type unless you set one; --json adds JSON content type and accept headers. The tool follows the same rules, so the generated code sends what curl would have sent.
What does not carry over
Some curl behaviour has no line-for-line equivalent, and the notes say so instead of guessing:
- Files: -d @file, -F file=@path and -b cookiefile read files on your machine. The code refers to the same path, which must exist where the code runs.
- Redirects: curl only follows them with -L; fetch, axios, requests and Go follow by default. Where the library can, the code turns that off to match (requests' allow_redirects, Go's CheckRedirect, axios maxRedirects).
- Browser limits: in browser fetch, headers such as Cookie, User-Agent, Referer and Host cannot be set; they are removed with a comment. Browser requests are also subject to CORS, which curl never is.
- -k / --insecure turns off certificate checks. Each target says how, with a warning to keep it out of production.
- Shell variables such as $API_KEY stay as text, and the notes list them: read them from the environment in your code.
- Windows PowerShell 5: curl there is an alias of Invoke-WebRequest; the tool reads the command as real curl.exe.
Credentials and history
If the command contains a token, password or cookie, the tool says so in bold. Generated code with a real key in it tends to end up committed, pasted into chat or logged. Move the value into an environment variable before you save the file. The same applies to the terminal: commands you type are kept in shell history files. Converting curl commands without leaking secrets explains how to keep keys out of history and code. For the response, the JSON formatter and JWT decoder help.