TK TaskKit
Developer Tools

cURL ↔ fetch

Convert cURL commands to JavaScript fetch() calls and back, in your browser.

Input
Output
Paste a command on the left, see the converted form on the right.

Inputs stay on this device. Every developer tool on TaskKit runs entirely in your browser. Tokens, payloads, and pasted text are not transmitted to TaskKit servers or third parties.

What this tool does

Converts cURL commands to JavaScript fetch() calls and back. Method, headers, request body, basic auth, and cookies all carry across in both directions. Useful when you've copied a curl from your terminal or a Chrome devtools "Copy as cURL" and want it as code, or when you want to share a fetch snippet with someone whose browser you'll never see.

When you'd use it

  • Translating a curl from a vendor's docs into your TypeScript client.
  • Reproducing a failing request from a bug report ("here's the curl") in a Node script.
  • Sharing a request with a teammate as a fetch snippet they can paste directly into a browser console.
  • Rewriting a working fetch as curl to file a bug with backend.

How it works

The curl direction parses the input as a shell command — quoted strings are respected, line continuations (\) are joined, and common flags (-X, -H, -d, -u, -A, -e, -b) are recognized. -u user:pass is rewritten as an Authorization: Basic header so it works in any HTTP client.

The fetch direction reads a fetch() call and pulls out the URL, method, headers, and body. It's a regex-based extractor, not a JS parser, so string literals work but template literals and computed values do not.

Notes

My fetch with a JSON template literal didn't translate. Right — the parser only reads literal strings. Replace \{ "id": \${id} }`` with the resolved string, or do that conversion first.

Does --data-binary get treated differently from -d? No. cURL distinguishes them (one preserves newlines, the other doesn't), but for fetch translation we treat both as the request body. If you depend on the binary semantics, you're past what fetch can express anyway.

What about HTTP/2 push, multipart upload, streaming? Out of scope. Multipart is the most common request — for that, build FormData in code rather than going through this tool.

Related tools