🔁 curl to JavaScript fetch Converter
Paste a curl command and get the equivalent JavaScript fetch() call — method, headers, body and basic auth translated for you.
POST https://api.example.com/login
How the curl to javascript fetch converter works
The converter tokenizes the curl command with a shell-aware parser (honouring single and double quotes, escapes and \-newline line continuations), then reads the common flags: -X/--request for the method, -H/--header for headers, -d/--data (and its variants) for the body, and -u/--user for HTTP basic auth (turned into an Authorization header). It infers POST when a body is present without an explicit method, adds a default Content-Type for form data, and emits a ready-to-run fetch() call with .then() handlers.
This handles the flags in the vast majority of copy-pasted curl commands — the ones you get from API docs, browser "Copy as cURL", and Stripe/GitHub examples. A few advanced cases are intentionally out of scope: multipart -F file uploads, cookie jars, and client certificates don’t map cleanly to a one-line fetch and are better handled deliberately. Because the parsing is local, any tokens or secrets in the command never leave your browser.
Frequently asked questions
How do I convert a curl command to fetch?
Paste the curl command and the tool outputs an equivalent JavaScript fetch() call, translating the method, headers and body. Copy it straight into your code.
Does it handle the request body and headers?
Yes — -H/--header become the headers object, and -d/--data (including --data-raw and --data-binary) become the body. Multiple -d flags are joined with & as curl does, and a default Content-Type is added for form data.
What about authentication?
The -u/--user flag is converted into an Authorization: Basic header (base64-encoded), which is how curl sends basic auth. Bearer tokens passed via -H "Authorization: Bearer …" are carried through unchanged.
Which curl features are not supported?
Multipart file uploads (-F), cookie jars and client certificates aren’t translated, because they don’t map cleanly onto a single fetch() call. The common flags from API docs and "Copy as cURL" all work.
Is my curl command uploaded?
No — parsing happens entirely in your browser, so any API keys or tokens in the command stay on your device. The tool works offline.