Skip to content
My Tiny Utils

Search tools

Type to find a tool, then press Enter to open it.

cURL to Fetch

Convert cURL commands to JavaScript fetch code instantly. Supports headers, auth, JSON bodies, form data, and all HTTP methods.

Processed locally in your browser — nothing is uploaded.

cURL to Fetch

0 characters

JavaScript fetch

Output appears here…

About cURL to Fetch

Paste any cURL command — copied from browser DevTools, API docs, or a teammate — and get equivalent JavaScript fetch code. The converter understands methods, headers, basic auth, JSON bodies, URL-encoded form data, multipart form data, and query parameters.

cURL commands use shell quoting, so the converter includes a real shell-style tokenizer: single quotes, double quotes, escapes, and line continuations all work the way they do in your terminal.

Common uses

  • Turn a “copy as cURL” from Chrome DevTools into frontend code
  • Convert API documentation examples into working fetch calls
  • Migrate shell scripts or Postman exports to JavaScript

Example

Input

curl -X POST https://api.example.com/users -H 'Content-Type: application/json' -d '{"name":"Ada"}'

Output

const response = await fetch("https://api.example.com/users", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ name: "Ada" }),
});

Limitations

  • Options with no fetch equivalent (like --compressed or --insecure) are reported but skipped
  • File uploads with @file references generate placeholder code you must adapt

Frequently asked questions

Is my cURL command sent to a server when I convert it?

No. Parsing and code generation run entirely in your browser, and nothing is transmitted or stored — which matters because commands copied from DevTools routinely contain live cookies, API keys, and Authorization headers.

How does the converter decide between GET and POST?

An explicit -X or --request flag always wins. Without one, the request becomes POST if it has a body (-d, --data, -F, or --json) and GET otherwise; -I maps to HEAD, and -G moves the data into the URL as query parameters and keeps GET.

What happens to cURL options that fetch can't express?

They are listed as warnings instead of failing the conversion. For example, --compressed is dropped because fetch decompresses automatically, --insecure has no browser equivalent, and --max-time becomes a suggestion to pass AbortSignal.timeout() as the signal option.

Does the converter understand shell quoting in my command?

Yes. It runs a real shell-style tokenizer, so single quotes, double quotes, backslash escapes, and backslash line continuations are interpreted the same way your terminal would interpret them.

Can I convert a cURL file upload like -F file=@photo.jpg?

Partially. The tool generates FormData code with the text fields filled in, but an @file reference can't be read from a pasted command, so it emits a TODO line where you supply the file yourself, for example from a file input.