cURL ↔ Fetch Converter

cURL → fetch()

fetch() → cURL

About the cURL ↔ Fetch Converter

curl commands are the standard way to share and document HTTP requests — copied straight from a terminal, API docs, or a browser's 'Copy as cURL' feature — but they need translating into JavaScript's `fetch()` when you want to call the same endpoint from code.

This tool converts a curl command into equivalent fetch() JavaScript, and builds a curl command from a URL, method, headers, and body — so you can move in either direction.

How it works

Common use cases

Frequently asked questions

Does this handle curl commands with multiple headers and a JSON body?

Yes — multiple `-H` header flags and a `-d`/`--data` JSON payload are parsed and translated into the fetch() `headers` object and `body` field respectively.

What if my curl command uses flags this tool doesn't recognize?

Common flags (`-X`/`--request`, `-H`/`--header`, `-d`/`--data`, and the URL) are supported; more advanced or unusual curl flags (like `--cookie-jar` or client certificates) aren't translated and would need manual adjustment in the generated code.

Does the generated fetch() code handle the response?

The converter focuses on constructing the request itself (method, headers, body); handling the response (like calling `.json()` or checking `.ok`) is left for you to add based on what your code needs to do with the result.

Can I convert a GET request with no body?

Yes — GET requests convert cleanly to a fetch() call with just headers and no body, since a body typically isn't sent with GET requests.

This tool runs entirely in your browser — nothing you enter is sent to a server. Read more in the Privacy Policy, or browse the full list of tools.