Skip to content
LovelyTools
EN

cURL to Python Requests

Convert a curl command into Python code using the requests library.

Processed locally on your device — nothing is uploaded.

About the cURL to Python Requests

API documentation and browser developer tools give you curl commands; your script needs Python. Paste a curl command and get clean code for the requests library: the URL, a headers dictionary, a JSON body turned into a real Python dictionary (with True, False and None), form data, and Basic auth as an auth tuple.

The method is taken from -X or inferred from the body, and unusual methods use requests.request. Tokens in the command never leave your browser. Supported flags are -X, -H, -d and the other --data variants, --json, -u, -A, -b, -e and -I.

How to use the cURL to Python Requests

  1. Paste a curl command.
  2. Review the generated Python.
  3. Copy or download the .py file.

Features

  • JSON bodies as Python dicts
  • Headers, cookies and auth
  • Any HTTP method
  • Local conversion

Supported formats

  • Plain text

Frequently asked questions

Why is Content-Type missing from headers?

With json=…, requests sets Content-Type: application/json automatically.

Is my text sent anywhere?

No. Everything runs in your browser, so nothing you paste is uploaded or stored.