BYTETOOLS

cURL to Fetch Converter

Paste a curl command and get a ready-to-use JavaScript fetch() snippet plus an axios version — method, headers, body and auth mapped automatically, all offline.

What is the cURL to Fetch Converter?

The ByteTools cURL to Fetch Converter turns a curl command — the kind you copy from API docs or a browser's network tab — into working JavaScript.

  • Handles quotes, escapes and multi-line backslash continuations
  • Maps -X, -H, -d/--data-raw, -u, -b, -A, -e, -I and -G
  • Detects JSON bodies and emits JSON.stringify with a formatted object
  • Generates both fetch() and axios versions
  • Lists any flags that were ignored or unsupported — no silent drops
  • Pure text parsing in your browser — nothing is executed or sent

How to use the cURL to Fetch Converter

  1. 1

    Paste your curl command, including multi-line commands with backslash continuations.

  2. 2

    Click Convert.

  3. 3

    Review the generated fetch() snippet and the axios alternative.

  4. 4

    Check the notes for any flags that were ignored, then copy the code into your project.

About the cURL to Fetch Converter

The ByteTools cURL to Fetch Converter turns a curl command — the kind you copy from API docs or a browser's network tab — into working JavaScript. It parses the command's flags and produces both a native fetch() snippet and an axios equivalent with the method, headers, body and basic auth carried across.

The parser understands quoting, escaping and line continuations, and maps the flags that matter: -X for the method, -H for headers, -d and its --data-* variants for the body, -u for Basic authentication, -b for cookies, -A for the user agent and -G for query-string GETs. JSON bodies are detected and emitted as a clean JSON.stringify call.

Nothing is executed and no request is ever sent — the command is parsed as pure text, entirely in your browser. Flags the converter ignores or cannot translate are listed so nothing disappears silently.

Frequently asked questions

How do I convert a curl command to JavaScript fetch?

Paste the command and click Convert. The tool reads the URL, method, headers and body from the curl flags and writes the equivalent fetch(url, options) call, ready to paste into your code. An axios version is generated alongside it.

Does this tool actually send the request?

No. The curl command is parsed purely as text in your browser — nothing is executed, no network request is made, and any tokens or credentials in the command never leave your machine.

How is curl's -u user:password converted?

Basic authentication becomes an Authorization header: the user:password pair is Base64-encoded and emitted as Authorization: Basic <encoded>, which is exactly what curl sends on the wire.

What happens to -d data when I also use -G?

curl's -G flag sends the data as a query string on a GET request instead of a request body. The converter reproduces that: the data parts are appended to the URL after a ? and the method stays GET.

Which curl flags are not supported?

File uploads with -F/--form and @file references, output flags like -o, and transfer options such as --retry have no direct fetch equivalent, so they are skipped and reported in the notes. Convenience flags like -s, -L and --compressed are ignored because browsers handle those behaviours automatically.

Why does the fetch version not include cookies automatically?

Browsers manage cookies themselves and fetch only sends them when credentials: "include" is set. If your curl command used -b to pass cookies, the converter writes them into a Cookie header so the request matches — but note that browsers block manual Cookie headers in some contexts; server-side runtimes like Node accept them fine.

Related tools