DeveloperKit

cURL to Fetch / Axios Converter

Convert cURL commands, including Copy as cURL from DevTools, into JavaScript fetch() or axios code. Free, private, and 100% in your browser.

cURL Command

Tip: in Chrome or Firefox DevTools, right-click a request in the Network tab and choose Copy as cURL (bash or cmd).

JavaScript (fetch)

Paste a cURL command to generate fetch() code.

Convert cURL to JavaScript

API docs and browser DevTools give you requests as cURL commands. This converter reads the command the way curl does, including quoting, the default form Content-Type of -d, and basic auth, and writes the equivalent JavaScript request.

cURL
curl https://api.example.com/users \
  -H 'Authorization: Bearer TOKEN' \
  --json '{"name":"Ada"}'
fetch()
await fetch("https://api.example.com/users", {
  method: "POST",
  headers: {
    "Authorization": "Bearer TOKEN",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ name: "Ada" }),
});

Features

  • fetch() and axios

    Switch between native fetch, which works in browsers and Node.js 18+, and axios, with async/await and optional error handling.

  • Real-world commands

    Handles bash quoting, $'…' strings, line continuations, and Chrome's Windows "Copy as cURL (cmd)" format with ^ escapes.

  • Smart bodies

    JSON becomes a readable object literal, form data becomes URLSearchParams, -F becomes FormData, and @file uploads are read with fs.

  • Clean headers

    Leaves out headers the browser sets itself (Host, Content-Length, sec-fetch-*, sec-ch-ua) so the code is short and works.

  • Most curl options

    -X, -H, -d, --data-raw, --data-urlencode, --json, -F, -u, -b, -A, -e, -G, -I, -L, -m, --oauth2-bearer, and more. Unsupported options are listed instead of silently dropped.

  • Private by design

    Commands are converted in your browser. API keys, tokens, and cookies in your cURL command are never uploaded.

How to Convert cURL to Fetch or Axios

  1. Copy a request as cURL from DevTools or API documentation.
  2. Paste it into the cURL Command box.
  3. Choose fetch() or axios and whether to include error handling.
  4. Review the notes below the code, then copy or download the JavaScript.

Frequently Asked Questions

How do I get a cURL command from my browser?

Open DevTools (F12), go to the Network tab, right-click a request, and choose Copy > Copy as cURL. Chrome offers bash and cmd variants; both are supported. Paste the command here to get the matching JavaScript.

Does the generated fetch code work in Node.js?

Yes. fetch is built into Node.js 18 and later. Code that uploads files uses readFile from node:fs/promises; in the browser, use a File from a file input instead.

Why are some headers removed?

Browsers do not let JavaScript set headers such as Host, Content-Length, Cookie, Origin, or the sec-fetch-* family, and they add them on their own. Removing them keeps the code clean. Uncheck "Remove browser-managed headers" to keep them for Node.js.

What Content-Type does curl -d send?

curl sends -d data as application/x-www-form-urlencoded unless you set another Content-Type. The converter keeps that behavior, so a JSON body sent with -d but without a Content-Type header is not silently turned into JSON.

fetch or axios: which should I use?

fetch needs no dependency and works everywhere. axios adds conveniences: it throws on 4xx and 5xx responses, serializes JSON automatically, supports request timeouts directly, and has interceptors.

  • URL Encoder / Decoder

    Percent-encode or decode URLs and query values, and unwrap double-encoded strings from logs in one click.

  • URL Parser

    Break a URL into protocol, host, port, path, and fragment, and edit its query parameters as a key-value table.

  • User-Agent Parser

    Identify the browser, operating system, device type, and bots from any User-Agent string, one or thousands at once.

  • HTTP Status Codes

    Search every HTTP status code, from 200 OK and 404 Not Found to 418 I'm a teapot, with causes and fixes.