Convert request objects from popular Python HTTP libraries into ready-to-run curl commands.
pip install curlify3import requests
from curlify3 import to_curl
req = requests.Request("POST", "https://httpbin.org/post", json={"date": "2026-08-10"}).prepare()
print(to_curl(req))
# curl -X POST -H 'content-type: application/json' -d '{"date": "2026-08-10"}' https://httpbin.org/postIncoming requests work the same way — log every request as a command you can replay:
from curlify3 import SENSITIVE_HEADERS, to_curl_async
@app.middleware("http")
async def log_request_as_curl(request, call_next):
logger.info(await to_curl_async(request, mask_headers=SENSITIVE_HEADERS))
return await call_next(request)to_curl()andto_curl_async()forrequests,niquests,httpx,httpx2,aiohttp,tornado,urllib.request, and server-sidestarlette/fastapi,aiohttp.web,django,flask/werkzeug,tornado- Every value quoted for the shell, so commands rendered from untrusted requests are safe to paste
- POSIX shell or Windows PowerShell output, one-line or pretty
- Per-call header filtering and secret masking
- A pytest plugin that attaches the commands of a failing test to its report, and a Robot Framework library
- Zero runtime dependencies, fully typed
shpaker.github.io/curlify3 — guides, supported request objects, payload handling, API reference.