---
title: "curl to Python Converter - requests Code Generator"
description: "Convert curl commands to Python requests code online. Headers, cookies, JSON, form data, auth, and proxies translated in your browser. Free, no signup."
url: https://webscraping.ai/tools/curl-converter/python
markdown_index: https://webscraping.ai/llms.txt
---
FREE TOOL

# curl to Python Converter

Paste a curl command, get working Python `requests` code — headers, cookies, JSON and form bodies, auth, proxies, and file uploads translated. Runs in your browser, no signup.

curl command

Conversion runs entirely in your browser — the command (and any tokens or cookies in it) is never sent to a server. Tip: DevTools Network tab → right-click a request → Copy as cURL.

```python

```

## Scraping a real site? Skip the blocks

Hand-copied curl headers go stale, and sites still block datacenter IPs. The same request through the WebScraping.AI API gets rotating proxies, headless Chrome rendering, and unblocking in one call — your custom headers and cookies are forwarded via the `headers` parameter. Shown with the [official client library](https://webscraping.ai/docs#sdks) of your choice:

```bash

```

[Get a Free API Key](https://webscraping.ai/auth/sign_up)[View API Documentation](https://webscraping.ai/docs)

2,000 free API credits · No credit card required

Convert curl to other languages: [curl to JavaScript](https://webscraping.ai/tools/curl-converter/javascript)[curl to Node.js](https://webscraping.ai/tools/curl-converter/node)[curl to PHP](https://webscraping.ai/tools/curl-converter/php)[curl to Go](https://webscraping.ai/tools/curl-converter/go)[curl to Java](https://webscraping.ai/tools/curl-converter/java) · [all languages](https://webscraping.ai/tools/curl-converter)

## What the generated requests code does

The converter produces idiomatic `requests` calls, not a literal flag-by-flag translation: `-H` headers become a `headers` dict and `-b` cookies a `cookies` dict; a JSON body is passed as `json=` (a Python dict, so `requests` sets the `Content-Type` and serialization for you) while form data uses `data=`; `-u` maps to `auth=(user, pass)`, `-F` file uploads to `files=` with opened file handles, `-x` to a `proxies` dict, `-m` to `timeout=`, and `-k` to `verify=False`.

Two curl-to-requests differences worth knowing: `requests` follows redirects by default, so `-L` needs no translation — and it sends `User-Agent: python-requests/…` by default, which many sites block on sight. That's why the converter keeps every header from your original command.

## Frequently asked questions

How do I convert a curl command to Python?

Paste the command into the converter above — it outputs Python requests code instantly, in your browser. Headers, cookies, JSON or form bodies, basic auth, proxies, timeouts, and file uploads are all translated. Nothing you paste is sent to a server.

Why use requests instead of urllib or httpx?

requests is the de-facto standard for synchronous HTTP in Python and what most scraping tutorials and libraries assume. urllib is standard-library but verbose; httpx has a nearly identical API to requests, so the generated code ports over with little more than an import change if you need async.

Why does the converter use json= for some bodies and data= for others?

If the curl command sends a JSON body (via --json or a Content-Type: application/json header), the converter emits it as a Python dict passed to json=, which is the idiomatic form. Form-encoded bodies become a dict passed to data=, and anything else is kept as a raw string.

The Python code gets a 403 but the same curl command works — why?

Sites can distinguish clients by TLS fingerprint and IP reputation, not just headers, and python-requests has a well-known fingerprint. Copying browser headers helps briefly; the durable fix is routing requests through rotating proxies and a real browser — which is what the WebScraping.AI API does in one call.

## Related

[Web scraping with Python](https://webscraping.ai/blog/web-scraping-with-python): From the first request to a working scraper, step by step.

[Python scraping libraries](https://webscraping.ai/blog/python-web-scraping-libraries): requests, BeautifulSoup, Scrapy, and friends compared.

[curl commands for scraping](https://webscraping.ai/blog/curl-commands-for-web-scraping): The curl options that matter for scraping, explained.

## Python code ready? Make it unblockable.

Same request, plus rotating proxies, headless Chrome, and JS rendering — one API call from Python.

[Start Free Trial](https://webscraping.ai/auth/sign_up)[View API Documentation](https://webscraping.ai/docs)
