Faruk ToolsVisit Portfolio

cURL Converter

Paste a curl command — single-line or multi-line — and get equivalent JavaScript fetch, axios, or Python requests code, with headers, JSON bodies, form data, and Basic auth all carried over.

Nothing leaves the browser. The command you paste — including any tokens or credentials in it — is parsed and converted entirely on this device. There is no network request, no logging, and nothing is saved.

const body = {
  "name": "Ada Lovelace",
  "role": "admin"
};

fetch("https://api.example.com/v1/users", {
  method: "POST",
  headers: {
    "accept": "application/json",
    "content-type": "application/json",
    "authorization": "Bearer YOUR_TOKEN",
  },
  body: JSON.stringify(body),
})
  .then((response) => response.json())
  .then((data) => console.log(data))
  .catch((error) => console.error("Request failed:", error));

Paste a curl command — including the multi-line kind with backslash continuations that Chrome DevTools, Firefox, and Postman all produce when you "copy as cURL" — and get equivalent JavaScript fetch, JavaScript axios, or Python requests code.

This isn't a lookup table of common patterns: it actually tokenizes the command the way a shell would (respecting quotes and line continuations), then walks curl's own flags (-X, -H, -d and its variants, -F, -u, -G, and more) to build a real request model, which is then rendered into each target's idiomatic shape — a bare fetch(url) for a plain GET, requests.request(...) so unusual methods like PURGE still work, real dict/object literals for JSON bodies (with true/false/null correctly converted to Python's True/False/None), and so on.

Everything runs in your browser. Nothing about the command you paste — including any tokens, cookies, or credentials it contains — is sent anywhere.

How to use this converter

  1. 1Paste a curl command into the box — a single line or the multi-line "copy as cURL" format both work.
  2. 2Switch between the fetch, axios, and Python requests tabs to see the equivalent code for each.
  3. 3Copy the snippet you need. JSON bodies, form data (-F), Basic auth (-u), and custom headers all carry over automatically.
  4. 4If a flag isn't supported (like --connect-timeout or a cookie-jar file), it's listed below the output so you know what was silently ignored rather than guessing.

Supported curl flags

FlagMeaningNotes
-X, --requestHTTP methodInferred as POST if omitted but -d or -F is present
-H, --headerAdd a headerMultiple -H flags are all preserved
-d, --data, --data-raw, --data-binaryRequest bodyAuto-detected as JSON, urlencoded key=value pairs, or raw text
--data-urlencodeURL-encode a data fieldValue is percent-encoded before joining the body
-F, --formMultipart form fieldA value starting with @ is treated as a file upload
-u, --userBasic authRendered as each library's native auth option where one exists
-G, --getSend -d data as a query string instead of a bodyForces the method to GET
-k, --insecureSkip TLS certificate validationNoted in the output; fetch has no equivalent option

Frequently asked questions

Why doesn't this support curl commands copied from Windows cmd.exe?+

Windows' cmd.exe uses a different quoting and line-continuation syntax (^ instead of a trailing backslash, doubled quotes instead of backslash-escapes) than bash/zsh. This tool targets the bash-style output that Chrome, Firefox, and Postman all generate by default — if you're on Windows, PowerShell's "Copy as cURL (PowerShell)" option or WSL's bash will both produce a compatible format.

Why did my JSON body come out as a raw string instead of a parsed object?+

The tool only treats -d's contents as JSON if it starts with { or [ and parses successfully. If your JSON has a syntax error, or if it's actually form-encoded data that happens to contain a brace, it falls back to sending the exact bytes as a raw string — which still works correctly, it's just less readable in the generated code.

Does the axios output need the axios package installed?+

Yes — the generated code assumes axios is already a dependency (npm install axios). The fetch output needs nothing extra in a browser or modern Node (18+); Python requests needs pip install requests.

What happens to flags this tool doesn't model, like --connect-timeout or --proxy?+

They're parsed (so they don't accidentally get mistaken for the URL or corrupt the rest of the command) but not translated into the generated code, since fetch/axios/requests each handle timeouts, proxies, and similar concerns differently. Any such flag is listed below the output so you know to configure it manually if you need it.

Is Basic auth (-u) handled securely?+

It's converted exactly as curl would send it — base64-encoded in an Authorization header for fetch, or via axios's/requests' native auth option (which do the same encoding internally). Basic auth is not encryption; it's only as safe as the HTTPS connection it travels over, same as with curl itself.