Paste from docs or from Chrome, Edge or Firefox DevTools (Copy as cURL, bash or cmd). Nothing is sent anywhere.
const res = await fetch("https://api.example.com/users", { method: "POST", headers: { "Content-Type": "application/json", "Authorization": "Bearer abc123" }, body: JSON.stringify({ "name": "Ada Lovelace", "role": "admin", "active": true }) }); const data = await res.json(); console.log(res.status, data);
What the command does
- Request
- POST https://api.example.com/users
- Headers
- Content-Type, Authorization
- Body
- 52 bytes
How to use
Paste a curl command
Paste the command into the box, or press an example. Backslash and caret line breaks, single and double quotes, and the $'...' strings from Chrome's Copy as cURL are all understood.
Pick a language
Press one of the popular languages, or choose any of the 19 targets from the menu. The code updates as you edit the command. What the command does summarizes the parsed method, URL, headers and options.
Copy or download the code
Press Copy or Download. Replace placeholders such as fileInput for form uploads, and move secrets like bearer tokens into environment variables before you commit anything.
Why cURL to Code Converter
- 19 targets, from fetch and Python to Go, Java, C#, Rust, PHP, PowerShell and HTTPie.
- Understands -X, -H, -d and its variants, --json, -F, -u, -b, -G, -I, -k, -L, -m, -x and --compressed.
- Reads Chrome's Copy as cURL in both bash and Windows cmd formats.
- Converts live in your browser, so API keys in the command stay on your device.
Supported curl flags
The converter covers the flags that change what is sent. Anything else is ignored, so check the generated code if your command depends on an option that is not listed here.
| Flag | Meaning in curl | In the generated code |
|---|---|---|
| -X, --request | Set the HTTP method | method: "PUT" or requests.request("PUT", ...) |
| -H, --header | Add a request header | Entry in the headers object or dictionary |
| -d, --data, --data-raw, --data-binary | Send a request body, joined with & if repeated | body, data, json= in Python, or the body option in each language |
| --data-urlencode | URL-encode the value before sending | Encoded text added to the body |
| --json | Send JSON with JSON Content-Type and Accept headers | Both headers plus a JSON body |
| -F, --form | Multipart form field or file upload | FormData, or data= and files= in Python |
| -u, --user | Basic authentication | Authorization header, auth option in axios, auth= in Python |
| -b, --cookie | Send cookies | Cookie header |
| -A, -e | User-Agent and Referer | Matching headers |
| -G, --get | Put the data in the query string | Data appended to the URL |
| -I, --head | Send a HEAD request | method: "HEAD" |
| -k, --insecure | Skip TLS certificate checks | verify=False in Python, a comment in JavaScript |
| -L, --location | Follow redirects | Redirect option where the library needs one |
| -m, --max-time | Give up after N seconds | Timeout setting in each language |
| -x, --proxy | Send through a proxy | Proxy setting, or a comment |
| --compressed | Ask for and decode gzip | Decompression option in PHP, C# and wget; automatic elsewhere |
Output targets
Each target writes idiomatic code for its library. Pick the one your project already uses, so no new dependency is needed.
| Group | Targets |
|---|---|
| JavaScript | fetch (browser), axios, Node.js fetch |
| Python | requests |
| PHP | cURL extension, Guzzle |
| Other languages | Go net/http, Java HttpClient, C# HttpClient, Ruby Net::HTTP, Rust reqwest, Swift URLSession, Kotlin OkHttp, Dart http |
| Command line | PowerShell Invoke-WebRequest, HTTPie, wget |
| Other formats | Raw HTTP request, JSON request details |