MockFoxAdvertise

curl to Python converter

Updated Free mock REST & WebSocket APIs

Paste a curl command and get clean Python code using the requests library — JSON bodies become json= dictionaries, forms become data= and uploads become files=.

POST https://mockfox.dev/api/fake/posts2 headersbody 52 chars

import requests

headers = {
    "Authorization": "Bearer YOUR_TOKEN",
}

json_data = {
    "title": "Hello",
    "body": "From curl",
    "userId": 1,
}

response = requests.post(
    "https://mockfox.dev/api/fake/posts",
    headers=headers,
    json=json_data,
    allow_redirects=False,
)

print(response.status_code)
print(response.text)

🔒 Converted in your browser — your command, tokens and URLs are never sent anywhere.

How to convert a curl command

  1. Paste the command into the box (multi-line commands with \ continuations are fine) — or copy one from DevTools with Copy as cURL.
  2. Pick the output language. The code updates as you type.
  3. Copy or download the code, and check any warnings about options that can't be converted.

How curl options map to requests

curlPython requests
-H 'Name: value'headers={"Name": "value"}
-d '{"a":1}' + JSON Content-Typejson={"a": 1}
-d a=1 -d b=2data={"a": "1", "b": "2"}
-F file=@photo.jpgfiles={"file": open("photo.jpg", "rb")}
-u user:passauth=("user", "pass")
-kverify=False
(no -L)allow_redirects=False

With json=, requests serialises the dictionary and sets Content-Type: application/json itself, so the converter drops the redundant header. Install the library with pip install requests; for async code, the same arguments work almost unchanged with httpx.

Need an endpoint to try your code against? Use the free fake REST API or test any HTTP status code.

Related tools

Frequently asked questions

Is my curl command sent to a server?

No. The converter runs entirely in your browser, so API keys, tokens and URLs in your command never leave your device.

Why does the code use allow_redirects=False?

curl doesn't follow redirects without -L, while requests does by default. The converter keeps curl's behaviour; delete the argument if you want redirects followed.

Can I use the output with httpx?

Mostly yes: replace requests with httpx. httpx uses follow_redirects instead of allow_redirects and doesn't follow redirects by default.

Your business here? Sponsor this tool from $16/week. See placements