Skip to content
100% Client-SideZero UploadPython requests Output

cURL to Python Requests Converter — Offline & Private

Paste a cURL command and get clean Python 3 requests code: json=json_data for JSON bodies, data= for form payloads, auth=(user, pass) for basic credentials, and True/False/None literals mapped from JSON. The converter runs completely offline in your browser.

  • Zero upload, ever

    Parsing and code generation run in your browser — URLs, headers, and tokens never touch a server.

  • Live 100 ms conversion

    Output updates as you type or paste, with one-keystroke copy via Cmd/Ctrl + Enter.

  • requests-native output

    json= and data= chosen automatically, exactly like hand-written requests code.

Paste a cURL command to convert

Examples
100% Client-Side: Tokens & credentials never leave your browser.

cURL command

Paste a cURL command — idiomatic code appears here instantly, converted entirely in your browser.

Technical documentation

json= versus data= — chosen for you

Python's requests library has two body parameters, and picking the wrong one causes subtle bugs. json=payload serializes the object and sets Content-Type: application/json automatically, while data=payload sends form-encoded or raw bytes. The converter inspects the Content-Type header, the --json shorthand, and the body's shape, then picks the correct parameter — JSON bodies become a json_data dictionary, everything else becomes a data string.

Nested JSON survives faithfully: arrays become lists, objects become dictionaries, and the literals are rewritten to Python — true and false become True and False, null becomes None, and strings are escaped with Python-safe quoting.

Auth, headers, and cookies

Basic auth from -u (or credentials embedded in the URL) becomes the idiomatic auth=(username, password) tuple, letting requests build the Authorization header at runtime. Bearer tokens and API keys sent via -H pass straight through into the headers dictionary unchanged.

Convenience flags translate naturally: -A/--user-agent fills a User-Agent header, -e/--referer becomes Referer, and -b/--cookie becomes Cookie — so the generated headers dict matches what curl would have sent on the wire.

Running the generated Python code

The snippet targets Python 3.7+ with the requests library — install it once with pip install requests. Each generated script prints the response body, using response.json() for JSON APIs or response.text otherwise, so you can paste it into a REPL and iterate immediately.

Standard verbs map to their requests functions (requests.get, requests.post, requests.put, requests.patch, requests.delete, requests.head, requests.options), while unusual methods fall back to requests.request("VERB", url, …) — the same fallback requests itself documents.

Query strings, encoding, and edge cases

URLs keep their query strings verbatim — no params dictionary needed — and -G with data flags is merged into the URL exactly like curl does. --data-urlencode values are percent-encoded during conversion, and repeated -d flags are joined with & the same way curl joins them before sending.

Multi-line cURL commands with backslash continuations, ANSI-C $'…' quoting from Chrome DevTools, and escaped quotes inside JSON bodies are all normalized before conversion, so pasting straight from a terminal or the macOS pbpaste buffer just works.

Frequently asked questions

Does the converter run offline?

Yes. The page is pre-rendered static HTML with a client-side transpiler — once loaded it needs no network, so commands with production tokens and cookies are converted entirely on your machine.

When does the output use json= instead of data=?

json= is emitted when Content-Type is application/json, the --json flag is used, or an untyped body parses as valid JSON. Anything else — form pairs, plain text, XML — becomes data= with the original content type preserved.

How are JSON booleans and null translated to Python?

Literals are rewritten during conversion: JSON true and false become Python True and False, and null becomes None. Nesting, lists, and dictionaries are preserved exactly.

How is basic auth converted for Python?

The -u flag becomes the requests auth=(username, password) tuple. If the command already carries an Authorization header (for example a bearer token), it is kept in the headers dict instead.

Which Python version does the generated code require?

Python 3.7 or newer, plus the requests library via pip install requests. No other dependencies are needed — the snippet uses only requests and the standard library.

Does it handle custom HTTP methods?

Yes. Common verbs become requests.get/post/put/etc., and anything else is emitted as requests.request("VERB", url, …), which supports arbitrary methods.