cURL to fetch

Turn a copied cURL command into fetch, Axios or Node code, headers and body included.

Turn a curl Command Into Working JavaScript

Every API documentation page and every browser "Copy as cURL" gives you a shell command. What you need is code. Translating by hand means unpicking shell quoting, remembering that `-d` implies POST, and getting the header object right — tedious work that is easy to get subtly wrong.

This converter parses the command properly, including quoting and backslash line continuations, and emits fetch, Axios or Node code. It runs entirely in your browser, which matters because the commands you paste routinely contain live API keys.

Key features

  • Real shell parsing — single and double quotes, escapes and backslash line continuations, not a naive split on spaces.
  • Three output targets — native fetch, Axios, or Node with undici.
  • Method inference — a `-d` flag without `-X` implies POST, as curl itself does.
  • Auth and cookies — `-u` becomes a Basic header, `-b` becomes a Cookie header.
  • JSON bodies formatted — a JSON payload comes out as a readable object rather than one long string.
  • async/await or promises — one tick switches the generated code between the two styles.
100% client-side — no data leaves your machine

This tool runs entirely inside your browser using native Web APIs. Your files and text are never uploaded to a server, never logged and never shared with third parties.

How to use: cURL to fetch

  1. Paste the curl command
    From docs, from Postman, or from your browser’s network tab via "Copy as cURL".
  2. Choose your target
    fetch for browsers and modern Node, Axios if that is your stack, or Node with undici. Tick async/await if you prefer it to promise chains.
  3. Review the code
    Method, headers and body appear as proper code, formatted and ready.
  4. Copy it
    One click. Remember to move any API key into an environment variable before committing.

Technical specifications

Processing locationEntirely in your browser — no server round trip
Data uploadedNone. Files and text never leave your device
PriceFree — no account, no trial, no usage cap
CategoryDeveloper
Works offlineYes, once the page has loaded
Browser supportChrome 90+, Edge 90+, Firefox 90+, Safari 15+
Interface languagesEnglish, 中文, हिन्दी, Español, العربية

Frequently asked questions

Is it safe to paste a command containing my API key?

Here, yes — parsing happens entirely in your browser and nothing is transmitted. Be much more careful with converters that process server-side, because pasting a live credential into a remote service is a genuine leak.

Which curl flags are supported?

The common ones: -X, -H, -d, --data-raw, --data-urlencode, -u, -b, -F, --compressed, -L and -k. Unsupported flags are ignored rather than silently changing the request.

Why does my converted request fail with a CORS error?

Because curl is not a browser and is not bound by the same-origin policy. Running the equivalent fetch from a page requires the server to send permissive CORS headers. Run it from Node instead, or proxy it.

Does it handle file uploads?

A `-F` flag becomes FormData, but the file itself cannot be represented — you will need to supply a File or Blob at that point in your code.

Related tools

Back to all tools