Curl to Python Converter

Paste a cURL command and get ready-to-use Python (Requests) code. ideal for testing APIs from documentation.

cURL Command
Python Requests

Convert cURL to Python Requests Online

This free tool allows developers to instantly convert cURL commands into ready-to-use Python Requests code. Whether you are copying examples from API documentation like Stripe, Twilio, or Postman, or debugging network requests from your browser, this converter saves you time by generating clean, idiomatic Python code.

Why use Python Requests?

The Python Requests library is the de facto standard for making HTTP requests in Python. It abstracts the complexities of making requests behind a simple API, making it easier to send HTTP/1.1 requests. Our tool ensures you get the correct syntax for headers, cookies, JSON payloads, and authentication methods immediately.

Supported Features

  • HTTP Methods: GET, POST, PUT, DELETE, PATCH, OPTIONS
  • Headers: Custom headers parsed from -H or --header flags
  • Data Payloads: JSON (-d with JSON) and Form Data parsing
  • Authentication: Basic Auth extraction from -u flag
  • Compressed: Handles --compressed flag gracefully

Example Conversion

If you paste a command like this:

curl -X POST https://api.example.com/login \
-H "Content-Type: application/json" \
-d '{"username":"user","password":"123"}'

Our tool will instantly generate:

import requests

url = 'https://api.example.com/login'
headers = {
    'Content-Type': 'application/json'
}
json_data = {"username":"user","password":"123"}

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