Online Tool Store Online Tool Store

cURL to Fetch Converter

Paste a curl command and see its equivalent JavaScript fetch() call, with headers and body mapped across — handy when porting an API example from docs into a script. Runs entirely in your browser.

🔒 This tool runs entirely in your browser. Your files are never uploaded to a server.

Example

cURL to Fetch Converter

curl -X POST https://api.example.com/v1/users \
  -H "Authorization: Bearer TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"Jane Doe","role":"admin"}'

Example shown — replace it with your own curl command.

Equivalent fetch() call

fetch("https://api.example.com/v1/users", {
  method: "POST",
  headers: {
    "Authorization": "Bearer TOKEN",
    "Content-Type": "application/json"
  },
  body: JSON.stringify({ name: "Jane Doe", role: "admin" })
});

How it works

  1. Paste a curl command copied from API docs or a terminal history.
  2. The method, headers, and body are mapped onto a fetch() call.
  3. Copy the JavaScript straight into your script.

FAQ

What curl options does this handle?

The common ones you'll hit when copying an example from API docs: -X/--request for the method, -H/--header for headers, and -d/--data for a JSON body.

Does the output work in Node.js too?

The generated fetch() call works in any modern browser and in Node 18+, which ships fetch built in — for older Node versions you'd need a polyfill like node-fetch.

Is my curl command sent anywhere?

No — the conversion happens entirely in your browser. Nothing, including any tokens in your command, is uploaded to a server.

How we compare

FeatureOnline Tool StoreRewriting the request by handPostman's "Generate code" panel
No account or app requiredYesYesNo
Fast for a single pasted commandYesSlowExtra steps
Headers and body mapped automaticallyYesManualYes

For a one-off curl example from docs, this is quicker than retyping the request by hand or opening a full API client.

Explore related tools

Embed this tool

Paste this on your own site — it stays free, and every file still stays in your visitor's browser, not yours or ours.