cURL to fetch, Axios and Python requests Converter

Paste a cURL command and get ready-to-run JavaScript fetch, Axios or Python requests code. The command is parsed in your browser and never sent to a server.

Updated November 19, 2026

cURL command

Handles quotes, $'...' strings from Chrome's "Copy as cURL", and line continuations. Use placeholders instead of real tokens or passwords.

Converted code

const response = await fetch("https://api.example.com/v1/users?notify=true", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN"
  },
  body: JSON.stringify({
    "name": "Ada",
    "email": "ada@example.com",
    "roles": [
      "admin"
    ]
  })
})
const data = await response.text()
console.log(response.status, data)

Notes

  • --compressed: fetch, axios and requests already send Accept-Encoding and decompress responses, so no code is needed.

How to convert cURL to fetch, Axios or Python

  1. Copy the command from your API docs, terminal or the browser's network tab (right-click a request, Copy as cURL).
  2. Paste it above. Pick JavaScript fetch, Axios or Python requests.
  3. Check any "Not converted" items and notes, then copy the code into your project.

Worked example

curl -X POST https://api.example.com/v1/users -H 'Content-Type: application/json' -d '{"name":"Ada"}' becomes fetch(url, { method: "POST", headers: {…}, body: JSON.stringify({ name: "Ada" }) }) in JavaScript, axios({ method: "post", data: { name: "Ada" } }) in Axios and requests.post(url, headers=headers, json=payload) in Python.

Working with Docker too? Try Docker run to Compose. Need types for the JSON response? Use JSON to TypeScript, and check a payload first with the JSON validator.

See also

Frequently Asked Questions (FAQ)

How do I convert a cURL command to fetch?

Paste the command and choose the JavaScript fetch tab. The method, URL, headers and body are mapped to a fetch call with await. JSON bodies become JSON.stringify(...) and basic auth becomes an Authorization header built with btoa.

Is my cURL command sent to a server?

No. The command is parsed with JavaScript in your browser and nothing is uploaded or stored. Even so, replace real API keys and passwords with placeholders before pasting into any website.

Which cURL options are supported?

The method (-X), headers (-H), data (-d, --data, --data-raw, --data-binary, --data-urlencode, --json), basic auth (-u), multipart forms (-F), -G, -I, user agent, referer, cookies, query strings, --compressed, -k and line continuations. Options that cannot be expressed, such as proxies and output files, are listed under Not converted instead of being dropped silently.

Why does a POST with -d get a form Content-Type?

curl sends -d bodies as application/x-www-form-urlencoded unless you set another Content-Type. The converter keeps that behaviour and adds the header so the request matches what curl would send. If the body is JSON and you did not set a type, it is still sent as curl would, with a note.

How are file uploads with -F handled?

Fields like -F file=@photo.png upload a file from disk. Browsers cannot read arbitrary paths, so the fetch and Axios code uses a placeholder for a File from an input element. The Python output opens the file by name.

What does --compressed do in the converted code?

It tells curl to ask for gzip or brotli and decompress the response. fetch, Axios and requests already do this automatically, so the converter adds nothing and notes it.

Can I copy a request from my browser into this tool?

Yes. In Chrome, Edge or Firefox open the network tab, right-click a request and choose Copy as cURL. The $'...' quoting those browsers use is understood.