cURL to Fetch

Paste a cURL command and get equivalent JavaScript fetch() code. Parses URL, method, headers, request body, and common flags like -d, -H, -X, and --data-binary.

About cURL to Fetch

This tool parses a cURL command and produces equivalent JavaScript using the fetch() API. It handles the most common cURL flags: -X / --request for method, -H / --header for headers, -d / --data / --data-binary for the body, plus the URL.

Options

  • Use async/await — Wraps the call in an async function with await, or uses .then() chains.
  • Send credentials — Sets credentials: 'same-origin' or 'include' for cookies.

How to use

  1. Copy a cURL command (e.g., from your browser's DevTools "Copy as cURL").
  2. Paste it into the input box.
  3. (Optional) Toggle async/await and credentials.
  4. Click Convert and copy the generated fetch code.

Frequently asked questions

Does it support $'...' ANSI-C quoted strings? Yes — the parser handles single quotes, double quotes, and ANSI-C quoted strings used by Chrome's "Copy as cURL".

What about -k / --insecure? fetch() always uses the browser's certificate store, so those flags are ignored (not applicable in browser context).

What about --cookie? Cookies are mapped to a Cookie request header in the generated code. You can also enable the Send credentials option for cookie jars.