CURL to Fetch Converter
Translate HTTP cURL requests into browser fetch() code and flag options Fetch cannot reproduce.
Paste one HTTP or HTTPS cURL request. Shell variables, command substitutions, file reads, multipart forms, client certificates, and proxy routing are not guessed.
JavaScript Fetch Code
Converted fetch() code will appear here.
Moving a tested cURL request into browser JavaScript
A cURL command describes more than an HTTP method and URL. Options can change where data is placed, add headers, follow redirects, read files, use client certificates, or alter TLS behavior. A browser fetch() request does not expose every one of those controls.
The converter therefore handles the request pieces that map cleanly to Fetch and stops when an unsupported option could change request semantics. It preserves body text rather than parsing and reformatting JSON, because changing whitespace or escaping can change signed requests and debugging comparisons.
What is converted directly
- HTTP and HTTPS URLs, including
--url. - Explicit methods from
-Xor--request. - Request headers from
-Hor--header; repeated names are emitted as header tuples so the source values are not lost before Fetch normalizes them. - Text bodies from
-d,--data,--data-raw, and literal--data-binaryvalues. -G/--getdata moved into the URL query string.--jsonwith the Content-Type and Accept defaults that curl adds when those headers are absent.
Browser Fetch is not curl
Browsers control headers such as Host, Content-Length, Cookie, Origin, and several Sec-* headers. Fetch also rejects request bodies on GET and HEAD, and it follows redirects by default while curl does not unless -L is present. When those differences prevent an honest conversion, the page warns or stops instead of emitting code that only looks equivalent.
Credentials deserve a second look
Authorization headers copied from DevTools may contain live API keys or bearer tokens. Generated code keeps allowed header values exactly as entered. Replace secrets before committing, sharing, or pasting the result into public code.
Options that need manual work
Multipart forms, file uploads, @file data, client certificates, proxies, DNS overrides, and shell expansion are left out deliberately. Each needs extra information that is not present as literal browser-request data. Silently approximating them would create a different request.
CORS is another boundary: a syntactically correct fetch request can still be blocked by the browser when the target server does not allow the page origin, method, or request headers.
Authoritative behavior to compare against
curl documents how options such as --data, --request, and --url change a transfer. The Fetch API defines a different browser request model, including RequestInit and browser-controlled request headers.
