Free tool

curl converter

Paste a curl command and get the same request as Python requests or httpx, JavaScript fetch, axios, Go, PHP or Rust code. It reads Chrome's Copy as cURL output for bash and Windows cmd, and lists any option it could not carry over.

Free · no sign-up · runs in your browser, nothing is uploaded

Shell
curl command
Python with requests

Paste a curl command and the code appears here.

Get a curl command from your browser

The fastest way to reproduce a request a website makes is to copy it from the browser's developer tools:

  • Chrome, Edge: DevTools, Network tab, right-click the request, Copy, Copy as cURL. On Windows you get two: Copy as cURL (cmd) and Copy as cURL (bash).
  • Firefox: Network Monitor, right-click the request, Copy Value, Copy as cURL. On Windows there is a POSIX and a Windows version.
  • Safari: Web Inspector, Network tab, right-click the request, Copy as cURL.

The bash version quotes values with '...' and uses $'...' for bytes like newlines. The cmd version escapes with ^ and ends lines with ^ instead of \. The converter detects which one you pasted; the Shell switch overrides it. A copied request includes your cookies and tokens, so treat it like a password.

How curl options map to code

These are the options that change the request, and what they become in three common targets:

curlMeaningPython requestsfetchGo net/http
-X POSTMethodrequests.post()method: 'POST'http.NewRequest("POST", ...)
-H "K: V"Headerheaders={...}headers: {...}req.Header.Set()
-d, --data-rawBody, form by defaultdata=body:strings.NewReader()
--jsonJSON body + headersjson=JSON.stringify()strings.NewReader()
-FMultipart formfiles=FormDatamime/multipart
-u user:passBasic authauth=(u, p)Authorization headerreq.SetBasicAuth()
-b "a=1"Cookiescookies={...}Cookie header (not in browsers)Cookie header
-GPut -d data in the queryparams=URLSearchParamsurl.Values
-LFollow redirectson by defaulton by defaulton by default
-kSkip TLS checksverify=Falsenot possibleInsecureSkipVerify
-m 10Total timeouttimeout=10AbortSignal.timeout()Client.Timeout

curl itself does not follow redirects without -L, but most libraries do. requests follows them for every method except HEAD, Go's client follows up to 10, and fetch follows them unless you set redirect: 'manual'. If the code must stop at a redirect like curl does, turn that off in the library.

curl to Python requests

A typical API call and the code the converter writes for it:

curl https://api.example.com/v1/items \
  -H 'Authorization: Bearer TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"name":"Widget","price":9.5}' -m 10
import requests

headers = {
    'Authorization': 'Bearer TOKEN',
}

json_data = {
    'name': 'Widget',
    'price': 9.5,
}

response = requests.post(
    'https://api.example.com/v1/items',
    headers=headers,
    json=json_data,
    timeout=10,
)
print(response.text)

With json=, requests serializes the dict and sets Content-Type: application/json for you, so that header is dropped from the dict. When the JSON has numbers too large for a float, the converter keeps the body as a string in data= so nothing is rounded. requests has no default timeout, so a request without timeout= can wait forever; add one even when the curl command has no -m. Prefer async code? Pick Python httpx, whose API is almost the same.

curl to fetch and axios

fetch is built into browsers and into Node.js 18 and later. In a browser, scripts cannot set forbidden request headers such as Cookie, Host, Content-Length and Accept-Encoding; the browser sets them itself. A cross-origin request also needs the server to allow it with CORS, which curl never checks. That is why a request that works in curl can fail from a web page. For Node.js, pick the Node.js target, which keeps every header.

const response = await fetch('https://api.example.com/v1/items', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer TOKEN',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: 'Widget',
    price: 9.5
  }),
  signal: AbortSignal.timeout(10000)
});
const data = await response.text();
console.log(data);

axios sends a plain object as JSON and parses JSON responses on its own, and it rejects the promise on 4xx and 5xx status codes, while fetch only rejects on network errors. To inspect the JSON response, paste it into the JSON formatter.

curl behaviors that surprise people

  • -d alone makes a POST with application/x-www-form-urlencoded, even when the data is JSON. Servers that expect JSON then reject it. Add -H 'Content-Type: application/json' or use --json (curl 7.82.0 and later), which also sets Accept.
  • -d @file removes newlines from the file. Use --data-binary @file to send it unchanged.
  • -X POST with -d is redundant. -X GET with -d sends a GET with a body; use -G to put the data in the query string instead.
  • --compressed asks for gzip, deflate or brotli and decompresses the answer. Most libraries do this by default; the code sets it only where needed.
  • Query strings must be URL-encoded. Check one with the URL parser, and read a Bearer token with the JWT decoder.

FAQ

How do I convert a curl command to Python?+

Paste the command above and pick Python requests (or httpx). Headers become a headers dict, -d becomes data=, a JSON body becomes json=, -u becomes auth=(user, password), -b becomes a cookies dict and -k becomes verify=False. Install the library with pip install requests and run the script.

How do I convert curl to JavaScript fetch?+

Pick fetch for browser code or Node.js for a server script. The URL is the first argument; -X, -H and -d go into the options object as method, headers and body. In the browser some headers, such as Cookie, cannot be set by scripts, and the request must pass CORS, so the converter leaves those out and says why.

How do I copy a request as cURL in Chrome?+

Open DevTools, go to the Network tab, right-click the request, then choose Copy and Copy as cURL. On Windows Chrome offers two versions: Copy as cURL (cmd) for Command Prompt and Copy as cURL (bash). This converter reads both and detects which one you pasted.

What does -d mean in curl?+

-d (--data) sends data in the request body. It makes the request a POST and sets Content-Type to application/x-www-form-urlencoded unless you set another one with -H. Several -d options are joined with &. With @, as in -d @file.json, curl reads the body from a file and strips newlines; --data-binary @file keeps the file exactly as it is.

What is the difference between --data, --data-raw and --data-binary?+

--data reads a file when the value starts with @ and removes carriage returns and newlines from it. --data-raw is the same but treats @ as a normal character, which is why browsers use it. --data-binary sends the data exactly as given, file contents included. --data-urlencode percent-encodes the value first.

Is it safe to paste a curl command with cookies or tokens?+

Here, yes: the command is parsed in your browser and never uploaded. When it contains a password, a Cookie, an Authorization header or a token, it is also kept out of the page URL. Be careful where you share the output, though. A session cookie works like a password, so turn on Hide secrets before you paste the code anywhere.

Can Postman import a curl command?+

Yes. In Postman, click Import and paste the curl command as raw text; it creates a request with the same method, headers and body. Postman can also show code for a request in many languages. This page does the same conversion without an account or an app.

Why does the converter warn about some options?+

Some curl options have no equal in the target library, or only change curl's own output: --retry, -o, -v and -w are examples. The converter lists every option it ignored or could only approximate, so you know what to add by hand instead of finding out from a failed request.

Sources: curl man page · Everything curl: HTTP POST · Requests: quickstart · Requests: advanced usage · MDN: Using the Fetch API · MDN: Forbidden request header · Go net/http · PHP curl_setopt · reqwest · Chrome DevTools: Network reference. Checked 2026-10-31.