How the command is read
The command is split into words the way a shell would split it, then read the way curl reads its options. Bash and zsh syntax is supported — single and double quotes, backslash escapes, \ at the end of a line, and the $'…' strings that browsers use in “Copy as cURL (bash)”. So is the Windows command prompt: ^ escapes and ^ line continuations, as in Chrome’s “Copy as cURL (cmd)”. The command is only ever read as text; nothing is executed and no request is sent.
Anything after a pipe, ;, && or a redirect belongs to another command and is ignored, with a note saying so.
What is converted
- Method and URL —
-X,--url,-I(HEAD), and POST when there is a body, as curl does. A URL without a scheme getshttp://, again as curl does. - Headers —
-H, plus-A(User-Agent),-e(Referer),-r(Range) and-b name=value(Cookie). - Bodies —
-d,--data-raw,--data-binaryand--data-urlencode, joined with&and sent asapplication/x-www-form-urlencodedunless you set a Content-Type;--jsonwith JSON headers; and-Ffields asFormData. A JSON body is written asJSON.stringify(…)so it is easy to edit. - Authentication —
-u user:passwordbecomes anAuthorization: Basicheader (UTF-8, Base64-encoded) and--oauth2-bearera Bearer header. - Query and timeout —
-Gmoves-ddata into the query string;-mbecomesAbortSignal.timeout().
What fetch() cannot do
Some curl options have no fetch() equivalent: skipping certificate checks (-k), proxies (-x), saving to a file (-o), cookie jars, client certificates, digest or NTLM authentication and retries. Each one in your command is listed above the code rather than silently dropped. Options that need no code — -L (fetch follows redirects anyway), --compressed, -s, -v — are listed separately.
Browsers also refuse to let a page set some headers, including Cookie, Host, Referer and Origin. The code keeps them, because they work when it runs in Node.js, and the notice says which ones a browser will ignore. Local files that curl would read (-d @file, -F field=@photo.jpg) cannot be read by fetch(): in the async/await style, form files use Node’s fs.openAsBlob (Node.js 20 and later); in the .then() style the line is left as a comment for you to pass a File or Blob.