Skip to content
Toolwright

Fetch to cURL Converter

Fetch to cURL Converter turns a JavaScript fetch call into the equivalent cURL command, including method, headers and JSON, form or file bodies. The code is only read, never run, and stays in your browser.

Tool 028 · Developer
Outside requests …How to checkRuns on this deviceWorks offline once opened

How to use Fetch to cURL Converter

  1. Paste the fetch(...) call, with its options object, from your code.
  2. Choose whether to follow redirects, compress, and put each option on its own line.
  3. Copy the cURL command. Read any notes at the top: they list values that came from variables and options curl cannot copy.

Frequently asked questions

Is my code run or uploaded?

Neither. The code is read as text by a small parser in your browser and is never evaluated, so nothing in it can execute. It also stays out of shareable links, because code often contains tokens.

What happens to variables such as ${token}?

The parser cannot know their values, so they are kept as ${token} in the command and a note asks you to replace them. Template strings and + joins of plain text are read in full.

Which parts of fetch are understood?

The address, method, headers (an object, a list of pairs or new Headers), and bodies written as a string, JSON.stringify(...), new URLSearchParams(...) or a FormData built with append. new Request(url, init) works too. Options curl has no use for, such as mode and cache, are listed in a note.

Why does the command have -L and a Content-Type I did not write?

fetch follows redirects and labels a plain string body text/plain, while curl does neither by default. The command copies fetch's behaviour so both send the same request. You can switch -L off.

Does it work in Windows cmd or PowerShell?

The command uses bash-style single quotes. In PowerShell or cmd, quote it differently or run it in Git Bash or WSL.

Next step

Need the reverse? Turn a cURL command into fetch code. Open cURL to Fetch Converter.

  1. 017

    cURL to Fetch Converter

  2. 041

    HTTP Header Explainer

  3. 056

    JSON Formatter & Validator

  4. 132

    URL Parser