DO IT EASY APP
English

cURL to Python converter

Paste a cURL command and get Python requests code. Headers, body, authentication and form files included.

  • No sign-up, no fees.
  • Converts a cURL command to Python requests code.
  • Headers, JSON body, form data, file upload and authentication.
  • Lists options it couldn't convert instead of hiding them.
  • What you type is processed, but never shared with anyone.

How to convert cURL to Python

The API docs show a cURL example but you work in Python. Three steps:

  1. Paste the command. Put the curl ... line (it can span several lines) into the cURL command box.
  2. Read the code. Python code using requests appears below. JSON bodies become Python literals (true → True).
  3. Copy. Take the code into your project with Copy.

What are cURL and requests?

cURL is a widely used command-line tool for making web requests; API documentation usually gives its examples as cURL. In Python, the most common way to make the same request is the requests library. This tool reads the cURL options and writes the matching requests call, so you don't have to translate each flag by hand.

Supported options

  • -X method, -H header, -d / --data / --data-raw body, --data-urlencode, --json
  • -u user:password, -F form field and file (@file), -b cookie, -A user agent, -e referer
  • -G (put data in the URL), -k (skip certificate check), -m (timeout), -L, --compressed

Anything it can't convert (like -v or -o) is listed as a warning above the box.

What you need to know

  • If the body is valid JSON it's sent with json=; otherwise data= is used.
  • If there's a body and no -X, the method is POST, just like cURL.
  • The generated code is a starting point; instead of embedding secrets in code, it's better to read them from environment variables.

Tips

Frequently asked questions

Is cURL to Python conversion free?

Yes, it's free with no sign-up.

Is the request actually sent?

Only code is generated and no request is made. What you type is processed, but never shared with anyone.

Does a command I got from "Copy as cURL" in the browser work?

Mostly yes. Options that browser developer tools produce, like -H, --data-raw and --compressed, are supported.

Which Python library does it use?

requests. If it isn't installed, run pip install requests.

Are passwords written into the code?

The username and password you give with -u are written into the code. Remember to remove them or move them to an environment variable before sharing.

Can I use it on my phone?

Yes.

Related tools