Free · No sign-up · Runs in browser

cURL → fetch

Paste any cURL command and get idiomatic JavaScript — fetch, axios, or raw XMLHttpRequest. Handles headers, methods, JSON and form bodies, Basic auth, and multi-line commands. 100% client-side.

cURL Command
fetch()✓ converted
fetch("https://api.example.com/users", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer eyJhbGciOi...",
  },
  body: JSON.stringify({
  "name": "Alice",
  "role": "admin"
}),
})
  .then((res) => res.json())
  .then(console.log)
  .catch(console.error);

About the cURL to Fetch Converter

This free online converter translates any curl command into idiomatic JavaScript — fetch(), axios, or rawXMLHttpRequest. Perfect when you grab a request from Chrome DevTools' "Copy as cURL" or from a vendor's API docs and need to paste it into frontend code. Everything runs in your browser; your commands never leave the page.

Supported cURL Flags

  • -X, --request — HTTP method
  • -H, --header — request headers (repeatable)
  • -d, --data, --data-raw, --data-binary, --data-urlencode — request body
  • -u, --user — HTTP Basic auth (encoded to Authorization)
  • -A, --user-agent, -e, --referer, -b, --cookie
  • Multi-line commands with trailing \\ are supported
  • Common no-op flags like --compressed, -L, -k, -s, -v are ignored

Smart JSON Detection

When the request body looks like JSON — either because theContent-Type says so, or because the body starts with{ or [ — the output usesJSON.stringify(...) with a pretty-printed literal, which is both more readable and avoids escaping issues with embedded quotes.

Common Use Cases

  • Chrome DevTools → "Copy as cURL" → paste into your React/Vue component
  • Stripe, Twilio, OpenAI docs → turn a quickstart into working code
  • Postman export → inline fetch for a one-off script
  • Shell script → migrate HTTP calls to a Node.js worker

Frequently Asked Questions

Does it support cURL from Windows cmd / PowerShell?

Yes, as long as you keep the curl prefix and quote arguments. Windows cmd uses double quotes with ^ escapes — strip those escapes before pasting. PowerShell cURL output usually just works.

Does it convert cURL cookies to credentials: "include"?

Not automatically. The -b flag is translated to aCookie header, which fetch will send only whencredentials: "include" is set on the same-origin or CORS-allowed request. Add that option yourself if needed.

What about file uploads (-F)?

Multipart form uploads are not currently emitted — you needFormData in JavaScript and runtime file handles. Convert the other flags with this tool and add the FormData part by hand.

Related Tools

Decode Authorization: Bearer tokens with the JWT Decoder. Encode request body strings for query parameters with the URL Encoder.

Three targets

fetch, axios, or XMLHttpRequest — pick whichever your codebase uses.

Smart JSON

Detects JSON bodies and emits JSON.stringify(...) with a pretty literal.

Fully private

Commands with Authorization headers and secrets never leave the browser.