Skip to content
shpakerPublic

About

Turn requests from requests, httpx, aiohttp, Django, Flask, FastAPI, Starlette and more into ready-to-run curl commands. Zero dependencies, fully typed.

Topics

Resources

Contributing

Security policy

Stars

5 stars

Watchers

1 watching

Forks

Repository files navigation

curlify3

PyPI Downloads Python Tests Docs

Convert request objects from popular Python HTTP libraries into ready-to-run curl commands.

pip install curlify3
import 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/post

Incoming 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)

Features

  • to_curl() and to_curl_async() for requests, niquests, httpx, httpx2, aiohttp, tornado, urllib.request, and server-side starlette / 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

Documentation

shpaker.github.io/curlify3 — guides, supported request objects, payload handling, API reference.

Changelog · Contributing · Security · MIT License

About

Turn requests from requests, httpx, aiohttp, Django, Flask, FastAPI, Starlette and more into ready-to-run curl commands. Zero dependencies, fully typed.

Topics

Resources

Contributing

Security policy

Stars

5 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages