cURL → JavaScript fetch

Paste a cURL command and get a ready-to-use fetch() snippet. Runs entirely in your browser.

HTTP · cURL · JavaScript fetch

Turn API documentation cURL snippets into starter fetch() calls. Paste a command with headers and body flags; get JavaScript you can drop into the browser or Node — generated locally, not sent to our servers.

cURL → fetch() Headers & body Common flags Copy-ready JS Client-side parse

Why convert cURL to fetch?

OpenAPI portals, Stripe-style docs, and support tickets almost always show HTTP examples as curl. Front-end engineers and many Node developers work in fetch or thin wrappers around it. Hand-translating -H headers, JSON bodies, and methods is tedious and error-prone — especially with escaped quotes and multiline \ continuations.

This tool parses common cURL shapes in your browser and emits a readable fetch(url, options) skeleton. It does not execute the request; it only generates code.

How to use it

  1. Copy a cURL command from docs or DevTools “Copy as cURL”.
  2. Paste it into the input (line breaks with trailing \ are fine).
  3. Click convert and review the generated JavaScript.
  4. Replace placeholder secrets, adjust credentials storage, and run from your app or the API Tester.

Flags commonly supported

cURLTypical fetch mapping
-X / --requestmethod
-H / --headerheaders object
-d / --data / --data-rawbody string
-u user:passBasic Authorization header
-A / --user-agentUser-Agent header
--url / positional URLFirst argument to fetch

Exotic options (certificate pinning, arbitrary --next chains, some multipart edge cases) may need manual cleanup. Treat output as a starting point.

Example

curl -X POST 'https://api.example.com/v1/items' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"name":"widget","qty":3}'

Becomes a fetch call along the lines of:

fetch('https://api.example.com/v1/items', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_TOKEN'
  },
  body: JSON.stringify({ name: 'widget', qty: 3 })
  // or body as the raw string from -d, depending on conversion
});

Secrets: “Copy as cURL” from a logged-in browser session often includes cookies and bearer tokens. Generate code on a trusted machine, strip credentials before sharing snippets, and prefer env-based secrets in real apps.

Browser CORS vs cURL

cURL is not subject to browser CORS. A request that works in the terminal may fail from a web page unless the API sends the right Access-Control-* headers. For local experiments against third-party APIs, use a backend proxy or the API’s official SDK. See also the CORS Header Builder.

FAQ

Does this run the HTTP request?

No. It only generates code. Use your app, a REST client, or the API Tester tool to send traffic.

Will every cURL command convert perfectly?

No. Shell quoting is messy. Verify headers and body, especially multipart uploads and binary data.

Is my command uploaded?

Parsing is local. Still avoid pasting production secrets on shared computers. Privacy Policy.

Related tools

Sponsored