Curl to Python Requests Converter
Convert curl commands copied from browser DevTools into Python requests or Feapder spider code instantly.
Paste a curl command and click Convert
Example Commands
Click any card to load it into the editor
Supported curl Flags
-X / --requestHTTP method (GET, POST, PUT...)-H / --headerAdd request header-d / --data-rawSend POST request body--data-urlencodeURL-encoded form data-b / --cookieSet Cookie header-u / --userHTTP Basic Auth (user:pass)-A / --user-agentSet User-Agent header-e / --refererSet Referer header-LFollow redirects (ignored in output)--compressedGzip compression (ignored in output)About Curl Command Converter
When debugging APIs or inspecting network requests in browser DevTools, curl commands are the most common export format. However, manually translating these into Python code is tedious and error-prone — especially when dealing with complex headers, cookies, or auth tokens.
This tool parses your curl command and generates clean, runnable Python code for the requests library or the feapder spider framework, preserving all headers, request body, authentication, and HTTP method.
How to Use
- 1. Open browser DevTools (F12) → Network tab → right-click any request → "Copy as cURL"
- 2. Paste the curl command into the left input panel
- 3. Choose output mode (requests or feapder), then click Convert or press Ctrl+Enter
Common Use Cases
Copy a curl command containing a Bearer Token or HTTP Basic Auth from browser DevTools, convert it to Python in one click, and skip manually assembling headers and auth parameters. The generated requests code runs directly in Jupyter Notebook or the terminal.
When migrating multiple API endpoints from documentation curl examples to Python automation scripts, convert each endpoint's curl command sequentially. Paste each result as a standalone function to quickly scaffold an API test suite.
Use the feapder mode to convert any target website's request curl into a feapder.AirSpider class. All original headers and auth info are preserved, giving you a production-ready starting template — just add data extraction logic in the parse method.
When a colleague or community member reports an API issue via a curl command, generate the Python equivalent with this tool. Run it in a local debugging script to quickly confirm the root cause, avoiding false leads caused by behavioral differences between curl and Python.
Batch-convert curl examples from a Postman Collection or API docs into requests code, then integrate them into pytest or GitHub Actions. Achieve automated API regression testing without writing lengthy requests boilerplate by hand.
Authentication & Credential Security
Three common authentication patterns appear in curl commands: HTTP Basic Auth (-u flag) is encoded into an auth tuple in requests output; Bearer tokens (-H 'Authorization: Bearer ...') are preserved as regular headers; cookies/sessions (-b flag) are passed via the Cookie header. All credentials appear in plaintext in the generated Python code — handle the output files with care.
Production best practice: Never commit generated code containing real credentials to a Git repository. Replace hardcoded tokens with os.environ.get("API_KEY"), or use python-dotenv to load sensitive values from a .env file. For feapder projects, manage authentication centrally in settings or middleware rather than hardcoding credentials in every Request.
In feapder mode, auth credentials are not directly injected into the request but appear as an inline comment. This is intentional — the feapder framework recommends handling authentication uniformly through download_midware middleware, avoiding repetitive declarations in each Request constructor and simplifying credential rotation across staging and production environments.
Common Pitfalls & Troubleshooting
- Missing Content-Type leads to data format misdetection: If a curl command lacks -H 'Content-Type: application/json' but the body is valid JSON, the converter attempts auto-detection. Not all APIs accept auto-detected formats. If the generated code returns HTTP 415 or a parsing error, check whether the Content-Type header is missing.
- Shell variables are not expanded: If your curl command contains shell variables like $API_HOST or $, the parser treats them as literal strings — no variable substitution is performed. Ensure the pasted curl command is fully expanded before conversion.
- Redirect behavior differences: The -L flag in the original curl enables redirect following. The generated requests code follows redirects by default (allow_redirects=True), so this flag is ignored. If your workflow depends on intercepting specific redirects (e.g. 302 handling), manually set allow_redirects=False in the generated code.