Category: Developer tools

cURL to fetch() Converter

System ideaMissing a tool?

Convert a curl command into a JavaScript fetch() call

Paste a curl command copied from a browser's network tab or an API's documentation and get an equivalent JavaScript fetch() call, with the method, headers and body carried across. Conversion runs entirely in your browser.

fetch() snippet
fetch("https://api.example.com/v1/items", {
  method: "POST",
  headers: {
    "Content-Type": "application/json"
  },
  body: "{\"name\":\"Ada\"}"
})
  .then((response) => response.json())
  .then((data) => console.log(data));

Everything on this page is processed in your browser. Nothing is uploaded.

What this tool does

API documentation and "copy as curl" browser menus both produce curl commands, but a front-end usually needs the same request as fetch(). This tool parses -X/--request, -H/--header, -d/--data (and its --data-raw, --data-binary and --data-urlencode variants), --url, -u/--user and a plain trailing URL, and reports a clear error instead of a wrong guess for shapes it does not recognise, such as multiple loose arguments or a flag it does not support.

How to use it

  1. Paste a curl command.
  2. Review the generated fetch() snippet.
  3. Copy it into your JavaScript.

Privacy

This tool runs entirely in your browser. Your input is never uploaded, stored or shared — closing the tab removes it.

Frequently asked questions

Is the request sent anywhere?
No. The command is only parsed and rewritten as text; nothing is executed.
Which curl flags are supported?
-X/--request, -H/--header, -d/--data (and --data-raw, --data-binary, --data-urlencode), --url, -u/--user for Basic auth, and common no-argument flags like -s, -L, -k and -i, which are safely ignored. Anything else is reported as an unsupported flag rather than silently dropped.
Why does it add a Content-Type header sometimes?
If the command has a body but no explicit Content-Type header, the snippet adds application/json, matching curl's own common default for JSON APIs. Remove or edit it if your request needs something else.