cURL to Code Converter
Paste a curl command and get the same request as JavaScript fetch or axios, Python requests, Go, PHP, Ruby, Java, C#, PowerShell or HTTPie.
How to convert curl to code
Paste your curl command
Paste or type it into the box, or press Try an example.
Choose the language
JavaScript, Python, Go, PHP, Ruby, Java, C#, PowerShell or HTTPie.
Copy or download
Paste the code into your project.
Worked example
This is what cURL to Code Converter gives for its own sample values. Open the tool above and change anything to try your own.
curl command
curl -X POST 'https://api.example.com/v1/orders?expand=items' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"customer":"ada","items":[{"sku":"A-1","qty":2}],"gift":true}'- Convert to
- JavaScript (fetch)
Code
const response = await fetch("https://api.example.com/v1/orders?expand=items", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
},
body: JSON.stringify({
"customer": "ada",
"items": [
{
"sku": "A-1",
"qty": 2
}
],
...About cURL to Code Converter
Turn a curl command, such as one copied from your browser's network tab or from API docs, into code for your language. Headers, JSON bodies, form fields, basic auth and common flags are understood.
FAQs
How do I copy curl from my browser?
In the network tab, right-click a request and choose Copy as cURL.
Is the code ready to run?
Mostly. Check cookies, redirects, file uploads and error handling.
Can I go the other way?
Use cURL Command Builder.