cURL to Python/JavaScript Converter
Convert a cURL command into equivalent Python (requests) or JavaScript (fetch) code, instantly in your browser.
How to use this tool
cURL commands are the standard way APIs document example requests, and “Copy as cURL” is a common way to grab a real request straight out of a browser's DevTools — but neither is directly usable in a Python or JavaScript codebase. This tool parses the command (headers, method, body, authentication, file uploads, and all) and generates working code in either language, so you can paste a captured request straight into a script.
For example, curl -X POST -H "Content-Type: application/json" -d '{"a":1}' https://example.com becomes a requests.post(...) call with a json= payload in Python, or a fetch(...) call with JSON.stringify(...) as the body in JavaScript.
Paste a cURL command into the box above — the code updates automatically as you type. Switch between Python and JavaScript, and click Copy to copy the generated code.
FAQ
Is this cURL converter free to use?
Yes, this tool is completely free to use with no limits on how often you can use it.
Does my cURL command get uploaded anywhere?
No. Parsing and code generation happen directly in your browser. Your command — including any tokens, cookies, or credentials it contains — never leaves your computer.
Which cURL flags are supported?
The ones that matter for reproducing a request: -X/--request, -H/--header, -d/--data (and its --data-raw/--data-binary variants), -F/--form for multipart uploads, -u/--user for basic auth, -A/--user-agent, -b/--cookie, -I/--head, -G/--get, and a positional or --url URL. Cosmetic flags like -s, -v, -k, -L, and --compressed are recognized and safely ignored, since they don't change what request gets sent.
How does it decide whether the request body is JSON?
If a Content-Type header is present, its value decides: anything containing "json" is treated as JSON, anything else is sent as a raw string. If no Content-Type was set at all, the tool falls back to checking whether the body actually parses as valid JSON — matching what nearly every real request means in practice, since curl itself doesn't guess based on content.
What happens with a malformed or incomplete cURL command?
The tool does its best to parse whatever it can — unrecognized flags are safely skipped rather than aborting the whole command. If it truly can't find a URL to send the request to, it shows a clear error instead of generating broken code.
Related Tools
Regex Tester
Test regular expressions with live-highlighted matches and groups.
JSON to Python Converter
Generate Python dataclasses from a JSON sample, with types inferred automatically.
Cron Expression Parser
Explain a cron expression in plain English and see its next 5 run times.
JSON to TypeScript Converter
Generate TypeScript interfaces from a JSON sample, with types inferred automatically.