Utilumo
LightDarkSystem
Guide1 min readUpdated August 26, 2026

How to convert cURL and fetch requests

Short answer

A cURL command and a fetch() call describe the same HTTP request pieces: URL, method, headers, and body. Convert them by preserving those pieces, then review browser-only differences such as CORS and automatic response compression.

Map the request parts

  1. URLUse the absolute request URL from the cURL positional argument or the first fetch() argument.
  2. MethodCopy -X or the fetch method option. If cURL sends data without -X, treat it as POST.
  3. HeadersConvert each -H line into a headers object, or each headers object entry into a -H flag.
  4. BodyMap --data-raw, -d, or fetch body to the request body. Use JSON.stringify only when the body is valid JSON.
Try it: cURL to Fetch ConverterPaste cURL and generate fetch code locally.Open tool
Try it: Fetch to cURL ConverterPaste a common fetch() call and generate a cURL command locally.Open tool
Browser fetch has browser rulesA request that works in cURL can fail in fetch when the target API blocks browser origins with CORS, redirects, credentials, or mixed-content rules.

References

Questions

Can every cURL command become fetch code?

No. Simple HTTP requests convert well, but shell variables, file uploads, client certificates, and command substitutions need manual review.

Why does cURL work when fetch fails?

fetch runs inside a browser security model. CORS and mixed-content checks can block browser JavaScript even when terminal cURL is allowed.

Does this send my data anywhere?

No. Utilumo's developer tools parse and transform input inside the browser tab. Nothing is uploaded, stored, or logged.

Keep reading