Dev Converters
HTTP

cURL to fetch Converter

Convert cURL commands to browser-compatible JavaScript fetch() calls. Preserves headers, methods, bodies, and query strings.

How it works

cURL is the universal HTTP client for terminals, and fetch is the universal HTTP client for browsers and modern Node. Copying a curl command from API docs or DevTools and translating it into fetch by hand is tedious — you have to re-quote the URL, rebuild a headers object, JSON-stringify the body, and remember to set the method.

This converter parses curl arguments the same way a POSIX shell would: backslash-newline continuations are stripped, quoted strings are respected, and `-H`, `-d`/`--data`, `--data-raw`, `--data-urlencode`, `-X`, `-u`, and `--cookie` flags are extracted. The URL is the last non-flag positional argument. If a body is present and no explicit method was set, POST is inferred.

JSON bodies are detected by looking at Content-Type or by trying `JSON.parse` on the raw body. When detected, the output uses `JSON.stringify` to keep the source readable. Form-encoded bodies become URLSearchParams. Basic-auth `-u user:pass` is converted into an `Authorization: Basic ...` header using `btoa`. Unknown flags are silently ignored so paste-from-Chrome-devtools works even when flags like `--compressed` are present.

Frequently asked questions

Does this support --data-urlencode?
Yes. Form-encoded bodies become URLSearchParams in the fetch output.
What about cookies and --cookie flags?
Cookies are emitted into the headers map as a single `Cookie` header. For cross-origin requests you may also need `credentials: "include"`.
Are multi-line curl commands supported?
Yes. Trailing backslashes in shell are stripped before parsing, so you can paste multi-line curl straight from a terminal.

Related tools