cURL to Fetch Converter
Paste a curl command, get ready-to-use JavaScript fetch() code.
This free online curl to fetch converter parses the method, URL, headers, body, and basic auth from a curl command copied out of API docs or a browser's "Copy as cURL" and turns it into clean fetch() JavaScript. No signup required, runs entirely in your browser.
How curl commands map to fetch()
Paste a curl command into the box above — the kind you'd copy from API docs, a Postman export, or a browser DevTools "Copy as cURL" action. The tool tokenizes it the way a shell would (respecting single quotes, double quotes, and backslash escapes, so a quoted URL or JSON body with spaces inside it stays intact as one argument) and then reads out the pieces fetch() needs: the HTTP method from -X/--request, the URL from the first non-flag argument, headers from each -H/--header flag, the request body from -d/--data/--data-raw/--data-binary, and basic auth credentials from -u/--user (base64-encoded into an Authorization: Basic header).
The Content-Type nuance with -d
curl's -d flag does not automatically send JSON. If you don't pass an explicit -H "Content-Type: application/json" header, curl sends the body as application/x-www-form-urlencoded — even when the body looks like a JSON object. This converter mirrors that behavior exactly: it only adds a Content-Type to the generated fetch() call if your curl command set one explicitly. If your API expects JSON, make sure your curl command (and therefore the generated code) actually declares that header.