cURL to Code Converter
Convert a curl command to Python requests, JavaScript fetch, Java HttpClient, Go net/http or PHP cURL code, with headers and body.
Runs in your browser. Nothing is uploaded.
How to use the cURL to Code Converter
- Pick the language you want with the switch - Python, JavaScript, Java, Go or PHP.
- Paste a curl command, for example from API documentation or from your browser's developer tools (right-click a request, then Copy as cURL).
- The code appears as you type. Switch language at any time and the same command is converted again.
- Read any notes under the code, for example about options with no equivalent or files the code expects.
- Copy the code or download it, ready to run.
From a curl command to working code
API documentation shows examples as curl commands, and every browser can copy a request from its developer tools as curl. Turning that into code by hand means translating each header, the body, the authentication and the options, and it’s easy to get one wrong. Paste the command here, choose a language, and you get readable code that sends the same request. Switch language to compare, or to hand the same call to a colleague who works in another stack: the command stays in the box.
What gets converted
- Method and URL, including query strings and
-G, which moves-ddata into the URL. - Headers from
-H, plus-A(user agent),-e(referer) and-b(cookies). - Bodies: raw
-ddata,--json, URL-encoded form fields with--data-urlencode, and multipart uploads with-F, including files. - Authentication with
-u user:password, turned into each language’s basic-auth helper. - Options such as timeouts (
-m), compression and-k.
JSON bodies become native data where the language makes that natural, such as json= in Python,
rather than an escaped string.
The languages
- Python uses requests, the most popular HTTP library, with
json=,data=andfiles=. - JavaScript uses
fetch, built into browsers and Node.js 18 and later, withawait. - Java uses
HttpClientfrom Java 11, with no extra dependencies. - Go uses
net/httpfrom the standard library and checks errors. - PHP uses the cURL extension, so options map almost one to one.
Check before you run it
Copied browser requests often include cookies and session tokens, so remove what you don’t need before sharing the code. When an option has no direct equivalent, the request reads a local file, or the command holds a password or token, a note under the code says so. The conversion runs entirely in your browser, and the last command you pasted is remembered here only on this device.
Frequently asked questions
Which libraries does the generated code use?
The standard choice in each language: requests for Python, the built-in fetch for JavaScript (browsers and Node.js 18+), java.net.http.HttpClient for Java 11+, net/http for Go and the cURL extension for PHP. Only Python needs an install, with pip install requests.
Which curl options are supported?
The common ones: -X, -H, -d and its variants, --json, --data-urlencode, -F, -u, -b, -A, -e, -G, -I, -k, -L, -m and --compressed. Anything else is listed under the code as ignored, so nothing is dropped silently.
Does the code follow redirects like curl?
Not always the same way: curl only follows redirects with -L, while requests and fetch follow them by default. For almost every API call that makes no difference; check the language's redirect setting if you rely on curl's exact behaviour.
What happens to -k / --insecure?
It becomes the language's way of turning off certificate checks, such as verify=False in Python. Only use that for local testing, because it lets anyone between you and the server read and change the traffic.
Is my curl command sent anywhere?
No. The command is parsed and converted in your browser. That matters because copied commands often contain cookies, tokens and passwords.
Tutorials
How to call a REST API from Java with HttpClient
Convert a curl PUT request into Java HttpClient code, run it as a single file, and turn it into a reusable method.
How to send JSON to an API with JavaScript fetch
Convert a curl --json example from API docs into fetch code, handle errors, and keep the API token out of front-end code.
How to turn a browser request into a Python script
Copy any request from your browser’s developer tools as cURL, convert it to Python requests, and trim it into a clean, reusable script.