Toolvore

cURL to Fetch

Convert a supported literal cURL request to reviewable JavaScript Fetch code without sending the request.

This tool processes its input contents in your browser instead of sending them to a processing service. Page, asset and fixed usage-measurement requests are described on the Privacy page.

Translate a supported literal cURL request into JavaScript Fetch code with explicit method, supported headers and body, without executing either request.

How to use it

  1. 1Paste one cURL command with a literal HTTP(S) URL.
  2. 2Generate the code; correct any unsupported option reported.
  3. 3Review credentials, browser restrictions and body before copying or downloading JavaScript.

Example

Input
curl https://example.com
Output
const response = await fetch("https://example.com", { method: "GET", credentials: "omit", redirect: "manual" });

Request excerpt; the complete file also handles hidden redirect responses, checks HTTP status and reads the response text.

What happens to your data

Commands and generated requests stay local. The destination is never contacted. Review authorization values before sharing the generated code.

Last updated November 2026

Turn a literal cURL example from an API guide into JavaScript Fetch code you can review. Paste one supported HTTP(S) request and generate a downloadable.mjs example containing its method, supported headers and inline body. The converter never contacts the destination and never executes the command.

How it works

The converter reads a bounded POSIX-style command with ordinary single or double quotes, escapes and line continuations. It supports separate -X or --request flags, supported -H headers, one inline data argument, an explicit HEAD request and redirect-following with -L. For supported data flags, the generated request carries the appropriate default content type unless you supplied one. The --json option also supplies the JSON Accept header. Generated code uses credentials:omit so browser cookies are not silently added. Without -L, redirect:manual prevents automatic redirect following; browsers hide those redirect response details, and the generated code reports that limitation. With -L, redirects follow browser Fetch rules, which may differ from cURL for redirected methods and bodies.

A shell command and a browser request are different environments. Variables, substitutions, pipelines, file references, multipart forms, repeated header names and unsupported flags are rejected rather than ignored. Browser-controlled headers such as Cookie, Host, Origin and Content-Length cannot be faithfully reproduced and stop the conversion. Fetch does not permit GET or HEAD bodies or CONNECT, TRACE and TRACK methods, so those combinations also produce an error. Forbidden method-override header values are rejected. Custom method case is preserved; standard methods that Fetch would normalize must be supplied in uppercase. This is a documented subset, not a general shell parser or an exact emulator for every cURL option.

The output still depends on browser CORS rules, the target server, authentication and your execution environment. A generated example is not proof that the endpoint will accept it. Authorization headers, URLs and body text remain in the generated code; inspect them before copying into a ticket, repository or another service. Inputs up to 128 KiB are processed locally. No request, credential verification, API discovery or response preview is performed by this page.

Common use cases

  • Adapt a supported API documentation example into browser JavaScript.
  • Review the exact method, header and body translation before integrating a request.
  • Create an executable syntax-checked starting point without running the original command.

Frequently asked questions

Does conversion send the request?+

No. The page only produces code. Nothing is sent to the target URL.

Why are some flags rejected?+

Ignoring a flag could change the request. Unsupported semantics fail with an explanation instead of generating misleading code.

Will Fetch bypass CORS?+

No. The generated code follows normal browser permissions and target-server rules.

Does it follow redirects?+

Only when -L is supplied. Otherwise the generated request uses manual redirect handling; browsers hide the redirect response details, so the generated code reports an error instead of silently following it.

Can it read a body from @file?+

No. Paste an inline body or adapt the generated code yourself. The converter never reads arbitrary files referenced by a command.