curl to Code Converter

Convert curl commands to Python, JavaScript (fetch & Axios), Go, or PHP code. Handles headers, JSON body, form data, auth, and cookies.

Parsed

MethodPOSTURLhttps://api.example.com/usersHeaders2BodyJSON
import requests

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer TOKEN",
}

payload = {"name":"Alice","email":"alice@example.com"}

response = requests.post(
    "https://api.example.com/users",
    headers=headers,
    allow_redirects=False,
    json=payload
)

print(response.status_code)
print(response.json())

About the curl to Code Converter

curl is the universal language for HTTP requests — API documentation, Postman exports, browser DevTools, and Stack Overflow answers all express requests as curl commands. But when you need to make that same request in application code, rewriting it manually is tedious and error-prone, especially for requests with multiple headers, JSON bodies, or authentication. This tool converts any curl command into idiomatic code in your language of choice.

Supported flags include -X (method), -H (headers), -d / --data-raw (body), -u (basic auth), -F (form fields), -b (cookies), -L (follow redirects), -k (insecure), and --compressed. JSON bodies are automatically detected and passed as native objects in Python (json=) and Axios (data:). The output uses the most idiomatic library for each language: requests for Python, native fetch or axios for JavaScript, net/http for Go, and curl_* functions for PHP.

All parsing runs locally in your browser using JavaScript. No curl commands, headers, or authentication credentials are sent to any server.

Frequently Asked Questions

How do I get a curl command from my browser?

Open DevTools → Network tab → right-click any request → "Copy as cURL". This copies the exact curl command the browser sent, including all headers and cookies. You can then paste it here to convert it to code.

How do I get a curl command from Postman?

In Postman, open a request → click the code icon (</>) on the right sidebar → select "cURL" from the language dropdown. Postman generates the complete curl command including the current auth and headers.

Why does the Python output use json= instead of data=?

When the body is valid JSON, the converter uses the json= parameter in Python's requests library, which automatically sets the Content-Type: application/json header and serializes the Python dict. Using data= with a JSON string works too but requires setting the header manually and is less idiomatic.

Does this support multipart file uploads?

Yes — -F key=value form fields are parsed and converted to Python's files= parameter. Note that actual file upload (-F file=@filename.jpg) requires additional handling in your code to open the file — the converter generates the structure but you'll need to replace the string values with file handles.