Skip to main content
Conversion Module

cURL to Python Converter (requests, httpx & aiohttp)

Paste any curl command and instantly get clean Python code for requests, httpx, or aiohttp.

Why use this tool?

Use this converter when you have a working curl command — from API docs, your browser's 'Copy as cURL', or a colleague — and need it as Python. It parses the flags for you and emits idiomatic code for requests, httpx, or aiohttp, correctly handling headers, JSON and form bodies, basic auth, and cookies so you don't translate them by hand.

Advertisement
cURL command
curl -X POST https://api.example.com/v1/users \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer token123" \
  -d '{"name": "Ada", "role": "admin"}'
import requests

url = "https://api.example.com/v1/users"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer token123"
}
json_data = {
    "name": "Ada",
    "role": "admin"
}

response = requests.post(url, headers=headers, json=json_data)
print(response.status_code)
print(response.text)

Runs in your browser. Supports headers, JSON & form bodies, basic auth (-u), cookies, multipart (-F), -k (verify=False) and -L (follow redirects).

Tool facts

Supported Python
Python 3.x (requests, httpx, or http.client)
Input limit
Limited only by your device
Last reviewed
2026-08-25

What it can't do

  • Send the request — it only converts the curl command into Python code.
  • Translate advanced curl flags with no Python equivalent (a few are skipped).

About cURL to Python Converter

Developers constantly move between curl and Python: browser dev tools and most API references give you a curl command, but your automation, scraper, or integration is written in Python. Translating headers, request bodies, authentication, and flags like -k or -L by hand is tedious and error-prone.

This tool tokenizes the curl command exactly like a shell would — respecting quotes and backslash line-continuations — then rebuilds it as a normalized HTTP request. It detects the method, splits headers, parses JSON bodies into real Python dictionaries, converts form data, and maps basic auth (-u), cookies (-b), multipart uploads (-F), insecure mode (-k → verify=False), and redirects (-L).

You get ready-to-run output for three libraries: the ubiquitous requests, the modern sync/async httpx, and fully asynchronous aiohttp. Everything happens in your browser.

For a deeper walkthrough — handling headers, cookies, authentication and JSON bodies — see our guide on converting cURL commands to Python requests.

Frequently Asked Questions

Paste the curl command into the box and copy the generated Python. This tool parses the URL, method, headers, and body and produces requests code such as requests.post(url, headers=headers, json=json_data). Switch the output tab to also get httpx or aiohttp versions.