Skip to content
migration.tools
curl to Python requests

Curl to Python requests converter

Turn a curl command from API documentation into a Python script. JSON bodies become real dicts with True, False and None, passed with json= so requests sets the content type for you.

curl command

Python requests

The result appears here as soon as there is input.

Processed on this device. Nothing you paste or drop is uploaded.

How to use it

  1. 1Paste your curl or drop a file onto the input panel.
  2. 2Adjust the options — the result updates as you type.
  3. 3Copy the Python requests or download it. Drop several files to convert a batch into one ZIP.

What is understood

Method (-X), headers (-H), JSON and form bodies (-d, --data-raw, --data-urlencode, --json), multipart uploads (-F), basic auth (-u), cookies (-b), user agent, referer, bearer tokens, -G query strings, timeouts and redirects.

The command is split the way a shell would, including single and double quotes, backslash line continuations and the $'…' quoting that Chrome and Firefox produce when you copy a request as cURL.

When the body is JSON, it is emitted as a native object rather than an escaped string, so you can edit it straight away.

Questions

How do I copy a request from my browser as curl?

Open DevTools → Network, right-click the request and choose Copy → Copy as cURL. Paste it here. Remove cookies and tokens you don't want in your code first.

Is the command — including my tokens — sent to a server?

No. The command is parsed in your browser. Nothing is transmitted and the request itself is never executed.