cURL Converter: Convert cURL to Python, JavaScript & Go
Turn any cURL command into Python, JavaScript or Go.
POST https://api.example.com/v1/messages · 2 headers · body
import requests
url = "https://api.example.com/v1/messages"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer sk-test-123",
}
payload = {
"model": "gpt-4o-mini",
"stream": False
}
response = requests.post(url, headers=headers, json=payload)
print(response.status_code)
print(response.text)Join the Veojson dispatch
Get the weekly Veojson dispatch on API tooling, HTTP debugging and integration patterns.
One email, no spam, unsubscribe any time.
cURL to JSON
The converter reads every -H header into an object and, when the Content-Type is JSON, parses the -d body as JSON. This is the exact output it produces for the command below.
curl -X POST https://api.example.com/v1/users \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-test-123" \
-d '{"name":"Ada","role":"admin","active":true}'{
"method": "POST",
"url": "https://api.example.com/v1/users",
"headers": {
"Content-Type": "application/json",
"Authorization": "Bearer sk-test-123"
},
"body": {
"name": "Ada",
"role": "admin",
"active": true
}
}cURL flags and how they convert
| Flag | Meaning | Converted to |
|---|---|---|
| -X, --request | HTTP method | method (defaults to GET, or POST when a body is present) |
| -H, --header | Request header | headers object, one key per header |
| -d, --data-raw | Request body | JSON payload when Content-Type is JSON, otherwise raw string |
| -u, --user | Basic auth user:password | Authorization: Basic <base64> header |
| -F, --form | Multipart form field | Not converted yet — rewrite as a multipart upload in your client |
About this tool
Copy as cURL is the fastest way to capture a request from your browser devtools, but it is not code you can ship. This converter tokenizes the command exactly like a shell would — respecting quotes, escapes and line continuations — then rebuilds it as idiomatic Python requests, JavaScript fetch or Go net/http. Everything runs locally, so tokens in your Authorization header never leave the page.
How to convert cURL to Python
In Chrome or Firefox devtools, right-click a request in the Network tab and choose Copy → Copy as cURL. Paste it here and pick Python: you get a requests call with a headers dict and, when the content type is JSON, a parsed payload passed via json= so the body is re-encoded correctly.
Which cURL flags are supported
-X/--request, -H/--header, -d/--data (plus --data-raw and --data-binary), -u/--user for basic auth and --url are all parsed. Transport-only flags such as -L, -k, -s and --compressed are ignored because they have no direct equivalent in the generated client code.
Method and body inference
If no explicit method is given, the converter follows cURL's own rule: a request with a body becomes POST, everything else stays GET. JSON bodies are detected from the Content-Type header and converted to native structures — Python dicts with True/False/None, and a JSON string body for fetch and Go.
How to use cURL Converter
- 1
Copy the request as cURL
In your browser's DevTools Network tab, right-click the request and choose Copy → Copy as cURL.
- 2
Paste the command
Multi-line commands with \ continuations are fine — the parser handles them like a shell would.
- 3
Pick a language
Choose Python requests, JavaScript fetch or Go net/http.
- 4
Check and copy the code
Confirm the method and headers look right, then copy the generated code into your project.
Best practices
- Work from a real payload, not a hand-typed sample — encoding bugs hide in whitespace and Unicode.
- Keep the transformation reproducible: script it in CI once you have confirmed the output here.
- Never paste live credentials, customer records or production tokens into any web tool you have not audited.
- Version the inputs and outputs you rely on so a teammate can reproduce the same result later.
cURL Converter — Why it matters
Small integration details — an encoding, a claim, a header — are where most API bugs actually live, and they are expensive to find in production logs.
Getting them right in seconds keeps debugging sessions short and prevents malformed data from reaching downstream systems.
Related free & paid tools
| Tool name | Type | Key features | Link |
|---|---|---|---|
| curlconverter | Free | Open-source cURL → 30+ language converter | Visit |
| PostmanOffer | Freemium | Import cURL, then export runnable client code | Visit |
| Insomnia | Freemium | Desktop API client with cURL import/export | Visit |
| HTTPie | Freemium | Human-friendly CLI and desktop HTTP client | Visit |
Some links marked Offer are partner links. They cost you nothing extra and help keep these tools free.