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
- To convert a curl command: paste it into the top box and click Convert to get equivalent fetch() code.
- To build a curl command: fill in the URL, method, headers, and body in the bottom section and click Convert.
- Copy the generated code directly into your script or terminal.
Common use cases
- Turning API docs into working code: Converting a curl example from third-party API documentation directly into a fetch() call you can paste into your JavaScript project.
- Reproducing a browser request: Converting a curl command copied from a browser's Network tab ('Copy as cURL') into fetch() to replicate the exact request programmatically.
- Sharing a request with a teammate: Building a curl command from a fetch() call in your codebase so a teammate without Node.js can reproduce and debug the same request from their terminal.
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.