ToolVaults

cURL to JavaScript fetch() Converter

Paste a curl command and get a JavaScript fetch() equivalent. Handles method, headers, JSON and form bodies, and HTTP Basic auth (-u). Great for copying API docs into code.

Runs 100% in your browser — nothing is uploaded.

POST2 headersbodyhttps://api.example.com/users
JavaScript (fetch)
const res = await fetch("https://api.example.com/users", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer sk_test_abc",
  },
  body: "{\"name\":\"Ada\",\"role\":\"admin\"}",
});
const data = await res.json();

Frequently asked

Which curl flags are supported?

-X/--request, -H/--header, -d/--data/--data-raw/--data-binary/--data-urlencode, -u/--user (Basic auth), --url, and the positional URL. Flags that don't map to fetch (-k, -L, --compressed, -s, -v, -o) are silently ignored.

Does it work with multi-line curl?

Yes — line-continuation backslashes are handled, so you can paste directly from a `curl` example in docs.

What about Node vs browser fetch?

The output is standard `fetch()` compatible with modern browsers and Node 18+. `Authorization: Basic …` is generated for `-u user:pass`; other auth schemes need to be added by hand.

Related tools