Zero Signup ToolsFree browser tools

Developer Tools

cURL to Python Converter

Paste a curl command and get Python requests, http.client, or urllib code. Headers, JSON, form data, basic auth, and multipart parts handled in your browser.

Or load a preset

The curl command is parsed locally in your browser. Tokens, headers, auth values, and request bodies never leave your device.

What gets converted

Method and URL
-X / --request sets the method explicitly. Without it, a body forces POST and -G with -d folds the data into the URL and forces GET. For requests, query strings with two or more pairs become a params= dict.
Headers and auth
Every -H / --header becomes a headers entry. -u / --user becomes an auth=(user, pass) tuple in requests, or a Base64 Authorization header in stdlib outputs.
JSON and form bodies
-d values that parse as JSON become a Python dict passed as json=. Form- urlencoded bodies become a data= dict so requests sets the Content-Type for you.
Multipart and TLS
-F parts become the requests files= dict, opening any @file reference with open(...). -k / --insecure maps to verify=False and an unverified SSL context.

How to use

  1. Paste a curl command on the left, or click Load sample to start with a typical POST plus JSON body example.
  2. Pick one of the preset commands below the input (GET with query string, POST JSON, form-urlencoded login, basic auth, multipart upload) to see the converter working on common shapes.
  3. Choose an output style: requests for the third-party library, http.client for the stdlib, or urllib for restricted environments. The code regenerates instantly as you switch.
  4. Read the summary card for the detected method, URL, header count, and body type, then copy the generated Python with the Copy code button.
  5. Check any warnings for ignored flags (-o, --proxy, --max-time) or @file placeholders in multipart parts so you can wire them up in your script.

About this tool

cURL to Python Converter takes a curl command (the kind you copy from API docs, browser DevTools "Copy as cURL", or a Postman export) and turns it into a Python script you can run immediately. The parser tokenizes the command the way a POSIX shell would: single-quoted arguments stay literal, double-quoted arguments respect the standard backslash escapes, $'...' ANSI-C quoting expands the common control codes, backslash line continuations are folded, and short flags can be glued together (so -XPOST and -X POST both parse). It understands the flags people actually use: -X / --request for the method, -H / --header for headers, -d / --data, --data-raw, --data-binary, --data-ascii, and --data-urlencode for bodies, -F / --form for multipart parts (including @file references), -u / --user for HTTP Basic, -b / --cookie for the Cookie header, -A / --user-agent and -e / --referer for those convenience headers, --compressed and -k / --insecure as flags whose Python equivalents are spelled out, --url as an explicit URL form, and -G / --get to fold a data body into the query string. The method is inferred when -X is missing: a body forces POST, otherwise GET, with -G overriding back to GET. Bodies that parse as JSON are converted to a real Python dict and passed as json= so the Content-Type and serialization are handled for you. Form-urlencoded bodies become a data= dict so requests sets the Content-Type for you, and raw bodies pass through as a string. Query strings with two or more pairs are lifted into a params= dict for readability. Three output styles cover the searches developers actually run: the requests library with idiomatic verb calls (requests.get, requests.post, ...) including auth tuples, json=, params=, headers=, files=, and verify=False when needed; the http.client stdlib with urlsplit, an HTTPS or HTTP connection, and a base64 Authorization header when -u was used; and urllib.request as a stdlib alternative for environments where third-party installs are forbidden. Each output includes basic response handling so the snippet runs end-to-end, and any flags that do not have a Python equivalent (-o, --proxy, --max-time, --cert) are listed as warnings so you know exactly what was skipped. Useful for porting API docs into Python clients, rewriting browser DevTools traffic into a script, building reproductions for bug reports, and converting curl-based runbooks into Python automation. Parsing and formatting run entirely in your browser, so the URLs, bearer tokens, basic-auth credentials, cookies, and JSON bodies pasted here never leave your device.

Free to use. Works in your browser. No signup, no login.

Related tools

You may also like

All tools
All toolsDeveloper Tools