cURL to JavaScript fetch

Paste a cURL command, get equivalent JavaScript code using fetch (browser + Node 18+), axios (with interceptor / timeout / retry sugar), or https from the Node stdlib. Focused on the JS path — for other languages use the multi-language converter.

How to use the cURL to JavaScript fetch

Paste a cURL command. Pick a library: fetch is the modern default (no dependencies in Node 18+ or any browser); axios is conciser for retry / timeout patterns; https is the Node stdlib path when you can't add dependencies. TypeScript output adds the response type stub.

Converting cURL to JavaScript

A cURL command and a JavaScript HTTP call encode the same request very differently — headers become an object, the -d body needs JSON.stringify, basic auth turns into an Authorization header, and a multipart upload becomes FormData. Translating by hand is exactly the fiddly, error-prone work that introduces quoting and escaping bugs.

This converts a cURL command into JavaScript using fetch (browser and Node 18+), axios, or the Node https stdlib, with an optional TypeScript output. It focuses on the JavaScript path; for Python use the sibling cURL to Python converter, for many languages at once the multi-language cURL converter, and to assemble a request from form fields instead of converting one, the HTTP request builder.

Common use cases

  • DevTools to code — turn a “Copy as cURL” into a fetch or axios call.
  • Pick a client — emit fetch, axios, or stdlib https depending on your stack.
  • TypeScript — get a typed version with a response stub.
  • Documentation — show an API call as idiomatic JavaScript.
  • Quick port — move a shell request into a Node script.

Frequently asked questions

Which libraries can it target?

fetch (browser/Node 18+), axios, and the Node https stdlib module.

Does it output TypeScript?

Yes — the TypeScript option adds a response type stub.

What about other languages?

Use the cURL to Python converter, or the multi-language cURL converter for more.

Can it build a request from scratch?

For that, the HTTP request builder assembles one from form fields.
Embed this tool on your site

Free to embed, no attribution required (but appreciated). Paste this where you want the tool to appear: