Web & encoding
cURL to JavaScript fetch Converter
Copy a request from your terminal or API docs and get working fetch() code — headers, method, JSON body, basic auth and multipart forms all translated correctly.
- Runs 100% in your browser
- No signup · No uploads
- Free, unlimited use
cURL command
Examples: POST with JSON · GET with auth + query · Multipart upload — ⌘/Ctrl + Enter converts · drop a file to load it · processed locally
JavaScript output
Output is read-only. Use Copy, Download or Share to move it out.
How to use the curl to fetch tool
-
Paste the cURL command
Line continuations with backslashes, quoted strings and multiple -H flags all parse as they would in a shell.
-
Pick the output flavour
fetch is for the browser and modern Node; node-fetch adds the import for older Node; axios gives a config object instead of a call.
-
Drop it into your code
Bodies are pretty-printed and auth headers are generated (including Basic auth from -u). Replace any secret with an environment variable.
What makes this one different
- Parses -X, -H, -d, --data-raw, --json, -u, -b, -F and common flags
- JSON bodies are formatted as readable object literals inside JSON.stringify
- -u user:pass becomes a correct Base64 Basic Authorization header
- Multipart -F uploads generate FormData with append calls
- Three output flavours: fetch, node-fetch, axios
Privacy by architecture: this page contains no analytics that receive your input, and the conversion code runs in your tab. You can disconnect from the network after loading and keep working.
cURL to fetch — frequently asked questions
Is the generated fetch code production-ready?
The request translation is exact — method, URL, headers and body match what curl would send. What you should add before shipping: error handling (check response.ok), timeouts with AbortController, and retry logic for idempotent calls.
Where did my -k / --insecure flag go?
It is noted in a comment rather than translated, because node fetch verifies TLS by default and disabling that in code is a security decision. Fix the certificate instead; if you truly need it, set NODE_TLS_REJECT_UNAUTHORIZED=0 in a throwaway environment only.
How is Basic auth handled?
-u user:pass becomes an Authorization: Basic header with the credentials Base64-encoded, which is exactly what curl sends. Prefer tokens over basic auth where the API supports it.
Can it handle --compressed and redirects?
Compression is transparent in fetch, so --compressed needs no code. Redirects are followed by default in fetch, matching curl with -L; if you need manual redirect handling, set redirect: "manual".
Why does my curl command fail to parse?
Most failures come from unescaped quotes in complex shell strings or flags the parser does not recognise. The error names the token it choked on — usually it is quicker to fix the command than to guess.
Related tools
Searching for “curl to fetch converter”, “curl to axios”, “curl to javascript”? You are in the right place — browse all 19 tools.