cURL to Fetch Converter
Paste a curl command from API docs or your browser's "Copy as cURL" and get equivalent JavaScript fetch or axios code with the method, headers, body and authentication carried over.
How to convert curl to fetch
- Paste a curl command. Multi-line commands with backslashes and "Copy as cURL" output from browser dev tools both work.
- Choose fetch with async/await, fetch with .then, or axios.
- Copy the code. Replace any secrets before sharing it.
What gets converted
The converter reads the URL, method (-X), headers (-H), body (-d, --data, --data-raw, --data-binary, --json), form fields (-F), basic auth (-u) and cookies (-b). If a body is present without -X, the method becomes POST, matching curl's behavior. JSON bodies are turned into JSON.stringify of an object when they parse cleanly, which is easier to edit.
Browser-only options such as --compressed and -k (insecure) have no direct fetch equivalent and are noted in comments. Cookies and some headers (like User-Agent) cannot be set from browser JavaScript; they work in Node.js.
Everything is parsed locally, but be careful with commands copied from dev tools: they often include session cookies and tokens. Remove those before pasting code anywhere public.
Need a different tool? Suggest it here — we read every message.
Frequently asked questions
Does it work with "Copy as cURL" from Chrome?
Yes, including multi-line bash format.
Does fetch work in Node.js?
Yes. Node 18 and later include fetch globally.
Why is my Cookie header ignored in the browser?
Browsers block setting Cookie from JavaScript. Use credentials: "include" for same-site cookies, or run the code in Node.
Is my command sent anywhere?
No. It is converted in your browser.