About the cURL to Fetch
The command is read the way a shell reads it: single and double quotes, backslash escapes, ANSI-C strings ($'…', used by Chrome and Firefox in “Copy as cURL” for bodies with line breaks or quotes), line continuations, and the ^ escapes of “Copy as cURL (cmd)” on Windows. The options are then interpreted like curl does: -d makes the request a POST with the content type application/x-www-form-urlencoded, several -d are joined with &, --data-urlencode percent-encodes its value, -G moves the data into the query string, --json sets the Content-Type and Accept headers, -F builds a multipart form, -u becomes HTTP Basic authentication and -I a HEAD request.
The generated code is meant to be read and kept. A JSON body is written as JSON.stringify({ … }) with an object literal when that produces the same data, a form body as URLSearchParams when it encodes to the same bytes, and otherwise as a string with correct escaping — template literals for text with several lines. Multipart forms become FormData; files that curl reads from disk (@file) become a clearly marked placeholder in the browser and fs.readFileSync() in Node.js. --max-time becomes AbortSignal.timeout().
A browser does not let a page set every header. Cookie, Host, Referer, Origin, Content-Length, Accept-Encoding and all Sec- and Proxy- headers are forbidden header names in the Fetch standard and are silently ignored; they are kept in the code with a comment so you can see what the original request sent. Other differences from curl are listed under the code: fetch() follows redirects by default while curl needs -L, -k and -x cannot be reproduced in a page, and requests to another origin are subject to CORS. The conversion runs in your browser — tokens and cookies in the command are not uploaded.
How to use it
- In the browser's developer tools open the Network tab, right-click a request and choose Copy → Copy as cURL. Or paste any curl command.
- Choose the target: fetch for the browser or for Node.js, or axios, XMLHttpRequest, Python requests.
- Choose async/await or promise .then() style.
- Read the warnings and notes under the code, then copy or download it.