Updated August 26, 2026
cURL and fetch request parts reference
cURL and fetch both describe an HTTP request. This sheet maps the pieces that most converters can preserve without executing the request.
Request part mapping
| Request part | cURL | fetch() | Conversion note |
|---|---|---|---|
| URL | curl 'https://api.example.com/users' | fetch("https://api.example.com/users") | Use an absolute URL for copyable examples. |
| Method | -X PATCH | method: "PATCH" | cURL data flags imply POST when no method is set. |
| Header | -H 'Content-Type: application/json' | headers: { "Content-Type": "application/json" } | Header names are case-insensitive. |
| JSON body | --data-raw '{"name":"Ada"}' | body: JSON.stringify({ name: "Ada" }) | Only stringify valid JSON-like request bodies. |
| Compression | --compressed | browser-managed | Browsers handle response compression automatically. |
fetch is not terminal cURLfetch runs under browser security rules. CORS, credentials, redirects, mixed content, and forbidden headers can change what a converted request is allowed to do.
References
Questions
Does fetch automatically decompress responses?
In browsers, response compression is handled by the browser networking layer. You do not add a fetch option equivalent to cURL's --compressed.
Can fetch set every cURL header?
No. Browsers restrict some headers for security, and CORS can block access to the response.