Zero Signup ToolsFree browser tools

Developer Tools

cURL to Fetch Converter

Paste a curl command and get JavaScript fetch, Node 18 fetch, axios, or XMLHttpRequest code. Browser fetch and FormData ready, in your browser.

Or load a preset

The curl command is parsed locally in your browser. Tokens, headers, auth values, and request bodies never leave your device.

What gets converted

Method
-X / --request sets the method explicitly. Without it, a body forces POST and -G forces GET.
Headers
Every -H / --header becomes a headers entry. -A, -e, -b, and -u add User-Agent, Referer, Cookie, and Basic Authorization.
JSON bodies
-d / --data values that parse as JSON are pretty-printed inside JSON.stringify(...). Other strings stay literal.
Multipart and -G
-F parts become FormData, with @file flagged for replacement. -G with -d folds data into the URL as a query string.

How to use

  1. Paste a curl command on the left, or click Load sample to start with a typical POST plus JSON body example.
  2. Pick one of the preset commands below the input (GET with query string, POST JSON, form-urlencoded login, basic auth, multipart upload) to see the converter working on common shapes.
  3. Choose an output style: Browser fetch, Node 18+ fetch, node-fetch (CJS), axios, or XMLHttpRequest. The code regenerates instantly as you switch.
  4. Read the summary card for the detected method, URL, header count, and body type, then copy the generated code with the Copy code button.
  5. Check any warnings for ignored flags (-o, --proxy, --max-time) or @file placeholders in multipart parts so you can wire them up in your code.

About this tool

cURL to Fetch Converter takes a curl command (the exact thing you would copy from API docs, browser DevTools "Copy as cURL", or a Postman export) and turns it into a JavaScript request you can paste into a project. The parser tokenizes the command the way a POSIX shell would: single-quoted arguments stay literal, double-quoted arguments respect the standard backslash escapes, $'...' ANSI-C quoting expands the common control codes, backslash line continuations are folded, and short flags can be glued together (so -XPOST and -X POST both parse). It understands the flags people actually use: -X / --request for the method, -H / --header for headers, -d / --data, --data-raw, --data-binary, --data-ascii, and --data-urlencode for bodies, -F / --form for multipart parts (including @file references), -u / --user for HTTP Basic, -b / --cookie for the Cookie header, -A / --user-agent and -e / --referer for those convenience headers, --compressed and -k / --insecure as informational flags, --url as an explicit URL form, -G / --get to fold a data body into the query string, and a long list of recognized boolean flags (-L, -s, -i, -v, --http2, retry options, and more) that do not affect the JavaScript output. The method is inferred when -X is missing: a body forces POST, otherwise GET, with -G overriding back to GET. Bodies that parse as JSON are pretty-printed inside JSON.stringify, so the call site stays readable instead of dumping a single escaped string. Headers default to application/json when the body looks like JSON, or application/x-www-form-urlencoded otherwise (matching curl's own default for -d). Five output styles cover the cases the search query usually targets: Browser fetch with async/await, Node 18+ fetch with no imports, node-fetch with the CommonJS require, axios with the request config object (and an https.Agent for -k when relevant), and a vanilla XMLHttpRequest variant for older codebases. Each output includes basic error handling and a sensible response parse (response.json or response.text depending on Accept and the body type), and any unsupported flags are listed as warnings so you know what was ignored. Useful for porting examples out of API documentation, rewriting copy-as-cURL traffic from DevTools into a real client, prepping a quick reproduction in a node script, generating starter axios calls for a Vue or React app, and converting a curl-based on-call runbook into a TypeScript snippet. Parsing, formatting, and conversion all run locally in the browser, so the URLs, bearer tokens, basic-auth credentials, cookies, and JSON bodies pasted here never leave your device.

Free to use. Works in your browser. No signup, no login.

Related tools

You may also like

All tools
All toolsDeveloper Tools