Fetch / Axios to cURL Converter
Paste a fetch() or axios call and get the equivalent curl command. Handy for trying a sample from the docs, or the Copy as fetch output from your browser DevTools, in a terminal. The code is never run (no eval): the tool only reads literals such as strings, objects, and variables declared in the same snippet, and it makes no request. For the opposite direction, use the cURL to Fetch / Axios Converter.
🔒 Runs in your browser · Your data is never sent to a server
How to use
- Paste your code into the "fetch / axios code" box (code inside a function or async function works as-is).
- Toggle "Put each option on its own line" if you prefer a one-line command.
- Click "Copy" on the curl command in the result and paste it into your terminal.
Notes
- Supported calls are fetch(url, init), axios(config), and axios.get / post / put / patch / delete / head / options / request. It converts method, headers, body, credentials, redirect, and referrer, plus axios baseURL, params, data, auth, and timeout. Any other option is ignored and a warning is shown.
- The code is never evaluated. Only strings, numbers, objects, arrays, template literals, values declared with const / let / var in the same snippet, and JSON.stringify, new URLSearchParams / FormData / Headers are read. Results of function calls (such as a token getter) or outside variables cannot be known, so they are written as <name> placeholders.
- Instances from axios.create(), custom wrapper functions that build the request, and values defined in other files cannot be followed. If the code has several requests, only the first one is converted.
- The curl command is quoted with single quotes, so it works as-is in macOS and Linux shells. The Windows Command Prompt handles quotes differently; use PowerShell or Git Bash. If the code contains tokens or other secrets, check the command before you share or publish it.
Glossary
fetch
The built-in HTTP request API in browsers and Node.js 18+. You call it as fetch(url, { method, headers, body }).
axios
A JavaScript HTTP client library. You write axios.post(url, data, config), and objects are sent as JSON automatically.
cURL
A command-line tool for transferring data over HTTP and other protocols from a URL. -X sets the method, -H a header, and --data-raw the body.
FormData
An object for sending form fields and files as multipart/form-data. In curl it corresponds to the -F option.
FAQ
Is the pasted code executed?
No. The code is never run through eval or Function. The tool parses it with its own parser and only reads literals such as strings and objects, so no functions in your code are called and no request is made.
Can I convert "Copy as fetch" from my browser DevTools?
Yes. Paste the code from "Copy as fetch" in Chrome or Edge DevTools as-is. Options that do not affect curl, such as mode, referrerPolicy, and cache, are ignored without a warning, while credentials: "include" shows a warning.
What happens to variables and function results in my code?
Variables declared with const / let / var in the same snippet as strings or objects are resolved. Expressions whose value cannot be known, such as function return values or outside variables, are written as placeholders like <token> with a warning. Replace them with the real values.
How are axios params and object data converted?
params are appended to the URL query string using the same rules as axios (arrays become key[]=value). An object or array passed as data is written as a JSON string with --data-raw, and an application/json Content-Type header is added if you did not set one.
Share this page
