cURL → fetch converter
Paste a curl command — including your browser's Copy as cURL (bash) — and get ready-to-paste JavaScript fetch code. It all happens in your browser: nothing is uploaded.
Converts automatically as you type — nothing leaves your browser.
Your fetch code will appear here.
Want to keep this request, not just copy it?
A pasted snippet is gone by the next sprint. The same request as a .http file lives in your repo, re-runs whenever you need it, and diffs like the rest of your code.
Convert this cURL command to a .http file insteadRun .http files natively on Windows.
What it does
- Emits a fetch(url, { … }) call ready to paste
- Understands methods (-X), headers (-H), cookies, user-agent
- JSON bodies via JSON.stringify, others as template literals
- Basic auth (-u) → an Authorization header
- Parses your browser's Copy as cURL (bash) output
Keep the request, not just the code
Code goes stale the moment the endpoint changes. Keep the request as a .http file you can re-run and diff — convert cURL → .http instead, or open it in Karve.
Need C# instead? cURL → C#Why the same request works in curl but not in fetch
CORS applies in the browser, not in curl
curl sends whatever you tell it to. A page calling fetch on another origin can only read the response if the server allows it with Access-Control-Allow-Origin. Sending Content-Type: application/json, an Authorization header, or a method other than GET/HEAD/POST also triggers a preflight OPTIONS request, which the server must answer.
The fix is on the server (or a dev proxy), not in the snippet. mode: 'no-cors' doesn't help: it returns an opaque response whose body you can't read.
Cookies and credentials
In a browser, Cookie is a forbidden header, so a curl -b cookie copied into headers is silently dropped. The browser sends its own cookies according to credentials: 'same-origin' (default), 'include' (cross-origin too — the server must reply with Access-Control-Allow-Credentials: true and a specific origin, not *), or 'omit'.
Node.js vs the browser
- Node 18 and later have a global fetch, so the snippet runs with no package.
- Node has no CORS and no forbidden headers: a Cookie header is sent as written, and there's no cookie jar.
- Neither runtime rejects on 404 or 500. fetch rejects only on network errors, so check response.ok or response.status.
- curl's -k (skip TLS verification) has no browser equivalent. In Node, prefer trusting the development certificate over disabling verification.
Common questions
Why does my request work in curl but fail with a CORS error in fetch?
Browsers enforce CORS; curl doesn't. The server must allow your page's origin with Access-Control-Allow-Origin and answer any preflight OPTIONS request. The same fetch code runs without CORS checks in Node.js.
How do I send cookies with fetch?
In the browser, set credentials: 'include'. You can't set a Cookie header yourself. In Node.js, pass the Cookie header directly.
How do I convert a cURL command to JavaScript fetch?
Paste the command above — it's parsed in your browser into ready-to-paste JavaScript that calls the fetch API, with method, headers, and body filled in.
How are request bodies handled?
JSON bodies use JSON.stringify; others use a template literal. Bodies on GET/HEAD are skipped with a note, matching how fetch behaves.
Does it handle headers and Basic auth?
Yes — -H headers and -u Basic auth carry into the fetch options, including a browser "Copy as cURL".
Is my cURL command uploaded anywhere?
No. Conversion runs entirely in your browser — nothing you paste, including tokens, leaves your machine.
Keep the request as a .http file.
Generate fetch code when you need it — but keep, re-run, and debug the request in Karve, the native Windows workspace for .http files.
15-day free trial · No Karve account · No subscription