Fetch to cURL Converter

Turn a JavaScript fetch() call into an equivalent curl command, with headers, JSON body and auth carried across.

curl command

Paste a fetch() call above to see the curl command instantly.

No uploads. Your files stay on your device.

Free forever, no sign-up, no cookies. Buy me a coffee

How it works

Paste a fetch() call and this converter reads the request in your browser and writes the matching curl command as you type. It handles the common shapes: the URL (query string included), method, a headers object, array of pairs or new Headers(...), a string body, JSON.stringify(...), new URLSearchParams(...), plus credentials and redirect. Defaults follow the WHATWG Fetch Standard: no method means GET, and because redirect defaults to follow the command gets -L so curl behaves the same way. Quoting is POSIX shell single-quote escaping (IEEE Std 1003.1), where a quote inside the value becomes '\''; the Windows option uses cmd.exe double-quote escaping instead.

This is a best-effort translator, not a JavaScript engine. It reads literal values only: a URL or body built from variables, a template literal with a placeholder, a FormData body or a spread inside the options object cannot be resolved, so the tool says so in the notes under the output rather than guessing. Cookies attached by credentials: 'include' live in the browser, not in the command, so you have to add them with -b yourself. Everything runs locally in JavaScript, so bearer tokens and API keys in the request you paste never leave your device.

Frequently asked questions

How do I convert a fetch request to curl?

Paste the whole fetch() call into the box and the curl command appears as you type. The converter reads the URL and query string, the method, a headers object, array of pairs or new Headers(...), and a body given as a string, JSON.stringify(...) or new URLSearchParams(...). Pick bash/zsh or Windows cmd quoting and a multi-line or single-line layout, then copy the command or download it as a .sh file.

Why does the command include -L?

Because fetch() follows redirects by default under the WHATWG Fetch Standard, while curl stops at the first response unless you pass -L. Adding it keeps the command behaving like the browser call. If the fetch options set redirect to manual or error, the flag is left off and a note explains why, so the two always match.

What cannot be converted?

Anything that is not a literal value in the call itself: a URL or body built from variables, a template literal with a placeholder, a spread inside the options object, or a FormData body whose fields are added with .append() elsewhere in your code. The tool says so plainly in the notes under the output instead of guessing. Cookies from credentials: 'include' also live in the browser, not the command, so you add those with -b yourself.

Report a bug