cURL to Fetch Converter — Free, In-Browser
Convert curl commands to JavaScript fetch with header and body translation. Handles JSON, basic auth, and shows which flags are silently dropped by browsers.
cURL to Fetch Converter
Files never leave your browser0 lines · 0 chars · 0 B
0 lines · 0 chars · 0 B
You're on 7BusyBoss — 300+ free tools that run instantly in your browser. No signup, nothing uploaded.
Not every curl flag survives the trip to fetch
A curl command copied out of browser DevTools looks simple enough: curl -X POST https://api.example.com/users -H "Authorization: Bearer abc123" -H "Content-Type: application/json" -d '{"name":"Ada"}'. Converting the shape of it is easy. The hard part is that several flags and headers which work perfectly in curl either do nothing or are actively rejected once the same request runs inside a browser — and they fail quietly rather than loudly.
Which flags are actually recognised
The converter understands -X / --request for the method, -H / --header for headers, -d / --data / --data-raw / --data-binary / --data-urlencode for the body, -u / --user for basic auth, and --url for an explicit URL.
It also accepts -L / --location, --compressed, -s / --silent and -k / --insecure without producing anything, because each is either automatic in fetch or has no browser equivalent at all.
Every other flag is silently dropped. There is no error and no warning — --proxy, -A, --cookie and the rest simply vanish. This is the single most important thing to know about the tool, because a long DevTools command can lose parts of itself and still produce output that looks complete. Read the generated code against your original rather than assuming everything came across.
Cookies and forbidden headers fail silently in the browser
A curl command copied from DevTools usually carries a Cookie header, and often User-Agent, Host or Accept-Encoding too. The converter passes them through as ordinary headers because that is what they look like, but the browser will refuse to send them: these are forbidden header names that only the browser itself may set. Your fetch call runs, the header is dropped, and nothing tells you.
Cookies need a different mechanism entirely. Rather than a copied Cookie line, fetch uses the credentials option, and the values are easy to get backwards:
same-origin— the default. Cookies are sent automatically to your own origin, so a same-origin request needs no configuration at all.include— required for cross-origin requests. The server must also returnAccess-Control-Allow-Credentials: trueand name your exact origin, since a wildcard is not permitted with credentials.omit— never send them.
Basic auth is a header, not a credentials setting
Worth separating clearly, because the two get conflated: -u user:pass has nothing to do with the credentials option. Basic auth is encoded into an ordinary Authorization header, which the converter emits directly, and it works the same way in fetch as in curl. The credentials option governs cookies only.
JSON bodies are detected and pretty-printed
When the headers declare Content-Type: application/json and the body parses as JSON, the converter reformats it with indentation so the result is readable rather than one long escaped line. If the body is not valid JSON, it falls back to escaping it as a plain string. Data from --data-urlencode is joined with & and stays a string.
What to do after converting
The practical workflow is short. Delete the headers the browser controls — Cookie, User-Agent, Host, Accept-Encoding, Connection — since they will be ignored anyway and only obscure what your request actually sends. Then set credentials deliberately based on whether the call is same-origin or cross-origin. Finally, drop -L and --compressed from your thinking entirely: fetch follows redirects by default and decompresses response bodies automatically. See JSON to TypeScript for typing the response once the request works.
How to use the cURL to Fetch Converter
Takes about a minute. No signup, no download, your data stays in your browser.
- 1Open the tool. Scroll up to the cURL to Fetch Converter above — it loads instantly in your browser, no install needed.
- 2Enter your values. The fields come pre-filled with realistic defaults so you can see how it works — replace them with your own numbers.
- 3Read the result. The output updates instantly. Copy or share it — nothing is uploaded to a server, everything stays on your device.
Frequently asked questions
Common questions about the cURL to Fetch Converter.
What curl flags does this tool recognise?
Method flags -X and --request, header flags -H and --header, the body flags -d, --data, --data-raw, --data-binary and --data-urlencode, basic auth via -u or --user, and --url. It also accepts -L, --compressed, -s and -k without emitting anything, since those are automatic in fetch or have no browser equivalent.
What happens to a flag the tool does not recognise?
It is silently skipped, with no error and no warning. Flags such as --proxy, -A or --cacert simply disappear from the output. Because a long command copied from DevTools can quietly lose parts of itself this way, always read the generated fetch against your original command before relying on it.
Why will the converted code not set headers like User-Agent or Host?
Browsers forbid script from setting certain headers, including User-Agent, Host, Accept-Encoding, Connection and Cookie, because the browser controls them itself. If those lines appear in the output the browser drops them when the request runs, without any error. Remove them from the generated code so it reflects what is really sent.
How do I handle cookies, and what should credentials be set to?
Do not copy the Cookie header across — the browser will not send it. Use the credentials option instead. Its default, same-origin, already sends cookies to your own origin, so same-origin calls need nothing. Cross-origin calls need include, and the server must return Access-Control-Allow-Credentials true along with your specific origin rather than a wildcard.
Does the credentials option handle basic auth from the -u flag?
No, these are unrelated and often confused. Basic auth from -u is encoded into an ordinary Authorization header, which the converter emits directly and which works identically in fetch. The credentials option controls cookies only and has no effect on Authorization.
Community rating
Discussion (0)
No comments yet. Start the discussion.
Keep exploring
Related tools across 7BusyBoss — all free, all instant.