HandyTools Hub

cURL Converter

Convert cURL commands to fetch, axios, or Python code

Paste a cURL command — for example one copied from Chrome DevTools with “Copy as cURL” — and get ready-to-use code in JavaScript fetch, JavaScript axios, or Python requests. Headers, request body, HTTP method, and basic auth are all converted automatically, and unknown flags are reported as warnings instead of failing the conversion.

How to Use

  • Paste the command: Drop a full cURL command into the input area, line continuations and quotes included.
  • Convert: Click convert to parse the request and generate all three code targets instantly.
  • Pick a target: Switch between the fetch, axios, and Python tabs to see the generated snippet.
  • Copy the code: Use the copy button on the active tab to grab the snippet for your project.

Features

  • Parses Chrome DevTools “Copy as cURL” output out of the box
  • Supports -X, -H, -d (plus —data-raw/—data-binary/—data-ascii), -u, -A, and -G
  • Handles multi-line commands with backslash continuations and single/double quotes
  • Three generators: JavaScript fetch, JavaScript axios, Python requests
  • Unknown flags collected as warnings — the conversion never hard-fails on them
  • Runs entirely in your browser — no data is ever uploaded

Why Convert cURL to Code?

cURL is the lingua franca of API documentation and browser debugging: DevTools, API docs, and bug reports all speak it. But production code rarely does. Rewriting a long command by hand is error-prone — headers get dropped, JSON bodies lose their escaping, and the method silently reverts to GET. This converter parses the command the way a shell would, then emits idiomatic code for each target: fetch with a headers object and body, axios with its config object and auth option, and Python’s requests with a headers dict and auth tuple. The result compiles and runs as-is, so the request you debugged in the browser is the request your code actually sends.

Use Cases

  • Reproducing API calls: Turn a network request captured in DevTools into application code.
  • API integration: Convert examples from API documentation straight into fetch, axios, or requests.
  • Debugging: Move a failing backend request into a script you can iterate on quickly.
  • Learning: See how the same HTTP request looks across three different HTTP clients.

Tips for Best Results

Paste the entire command starting with curl — partial commands without a URL cannot be parsed. Check the warnings box after converting: flags like --compressed or --insecure are intentionally skipped, and the warnings list tells you exactly which ones. If your command uses -u for basic auth, the generated code embeds those credentials, so treat the copied snippet as sensitive. For JSON bodies, the converter preserves the payload verbatim; validate it with a JSON formatter if the API rejects it.

Frequently Asked Questions

What cURL commands does this converter support?

It parses commands copied from Chrome DevTools (Copy as cURL) and most hand-written cURL commands. Supported flags include -X/--request, -H/--header, -d/--data/--data-raw/--data-binary/--data-ascii, -u/--user, -A/--user-agent, and -G/--get. Line continuations (backslash at end of line) and quoted strings are handled automatically.

What happens with flags the converter doesn't know?

Unknown flags such as --compressed or --insecure never break the conversion. They are collected into a warnings list shown above the output, so you can see exactly what was skipped while still getting usable generated code.

Which languages can I generate?

Three targets: JavaScript fetch (the browser-native API), JavaScript axios (the popular HTTP library), and Python requests. Switch between them with the tabs above the output and copy each snippet with one click.

How is basic authentication handled?

Credentials from -u user:password are converted into the idiomatic auth mechanism of each target: a btoa-based Authorization header for fetch, the auth option for axios, and the auth tuple for Python requests.

Is my data sent to a server?

No. The conversion runs entirely in your browser — your cURL command, including any tokens or credentials it contains, never leaves your device.