Web Dev Helpers
cURL to fetch() Converter
Paste a curl command, get the equivalent JavaScript fetch() call.
curl command
Handles: -X, -H, -d / --data / --data-raw / --data-urlencode, -F, --form, --request, --compressed, --user, --location, cookie via --cookie. Silently drops flags that don't map to fetch() (like --insecure, --max-time). Escaped newlines in the command are collapsed.
JavaScript fetch()
const res = await fetch("https://api.github.com/repos/nodejs/node", {
method: "GET",
headers: {
"Accept": "application/vnd.github+json",
"User-Agent": "my-app/1.0",
},
});
const data = await res.text();About this tool
Turn any curl one-liner into an idiomatic JavaScript fetch() invocation. Handles the flags you actually use: -X / --request, -H / --header, -d / --data / --data-raw / --data-urlencode, -F / --form, -u / --user, -A / --user-agent, -b / --cookie, -e / --referer, --compressed, --location. Backslash-escaped newlines are collapsed, single and double-quoted arguments are parsed correctly. Everything runs in the browser.
FAQs
Which curl flags are dropped silently?
Flags that don't map to fetch() are ignored, e.g. --insecure, --max-time, --cert. If you need TLS options the fetch API doesn't support, you'll need a different HTTP client (Node's undici, Deno.request, etc.).
Does it handle POST with JSON?
Yes - -d '{"key":"value"}' becomes body: '{"key":"value"}' and the tool sets Content-Type to application/x-www-form-urlencoded unless you passed a -H 'Content-Type: application/json'.
What about multipart uploads (-F)?
The tool emits FormData with .append() calls for each -F field.