uncurl
Convert curl commands into equivalent python-requests code, from a CLI or a small Python API.
Repository Health
Technical Analysis
uncurl is a small Python library and command-line tool that turns a curl command into equivalent code using the Requests library. Because browsers like Chrome offer a “Copy as cURL” option in their network inspector, uncurl is a fast way to recreate captured browser or API requests in Python.
Beyond emitting ready-to-paste requests code, uncurl can parse a curl command into structured Python objects, exposing the URL, headers, cookies, method, and body as attributes you can inspect or reuse programmatically. It works both as a CLI (reading from arguments, stdin, or the clipboard) and as an importable API.
What You Get
- A
uncurlCLI that prints the python-requests equivalent of a curl command uncurl.parse()to get the requests code as a string from Pythonuncurl.parse_context()to access url, headers, cookies, method, and data as structured objects- Clipboard and stdin input support for quick copy-paste workflows
- Handling of common curl flags including headers, cookies, compression, and auth
Common Use Cases
- Recreating a browser request in Python after copying it as cURL from Chrome DevTools
- Turning API documentation curl examples into working Requests code
- Programmatically parsing curl commands into request components inside scripts and tooling
Under The Hood
Architecture - uncurl is compact: uncurl/api.py (~140 lines) holds the parsing logic, uncurl/bin.py (~20 lines) is the CLI entry point, and uncurl/__init__.py re-exports the public functions. The core parse_context uses Python’s argparse to tokenize a curl command into a structured context (url, method, headers as an OrderedDict, cookies, data, auth, verify), and parse renders that context into a python-requests call string. The CLI simply reads input from arguments, stdin, or the clipboard and prints parse’s output.
Tech Stack - Pure Python with a small dependency footprint declared in requirements.txt/setup.py, using the standard library argparse for command tokenization and pyperclip-style clipboard access for the paste workflow. Distributed as a classic setup.py package.
Code Quality - The repo includes a tests directory exercising the parser against representative curl commands. The code is straightforward and readable but predates modern typing (no type hints) and, per the repo health signals, has seen little recent maintenance (last release 2021), so edge cases in newer curl flags may be unhandled.
API Design - The public API is tiny and intuitive: parse for a code string, parse_context for structured objects. Combined with the copy-as-cURL workflow and clipboard/stdin input, the tool requires essentially no learning — a single command or one function call gets a usable result, which is its main appeal.