Convert cURL to Code
cURL → fetch / axios / Python
const response = await fetch("https://api.example.com/users", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer abc123",
},
body: "{\"name\":\"Ada\",\"role\":\"eng\"}",
});
const data = await response.json();
console.log(data);What is cURL to Code Converter?
Paste a cURL command and get back the equivalent JavaScript fetch, axios, or Python requests snippet. Handles headers (-H), body (-d), HTTP method (-X), basic auth (-u), and multi-line continuations (backslash-newline). Saves the common back-and-forth of manually translating a cURL from documentation into the language your project is written in.
How do I use cURL to Code Converter?
- Paste the cURL command into the input panel.
- Pick a target: fetch (JS), axios (JS), or requests (Python).
- Copy the generated code into your project.
When should I use cURL to Code Converter?
cURL to Code is for language translation. To test the request itself rather than generate code, use API Tester (shipping in a later phase).
Frequently asked questions
Which languages can I target?
JavaScript (fetch, axios), Python (requests), Node.js (http), Go, Ruby, PHP, Java, C#, Rust, and raw HTTP. Output uses idiomatic style for each language.
What does it do with auth and cookies?
Headers for Authorization, Cookie, and API-key variants are translated into the language's preferred idiom (e.g. requests auth=, axios auth { }).
Does it handle multipart / file uploads?
Yes; -F flags become the right multipart construction in each language. Binary file uploads are represented as a file read (open / fs.readFileSync / etc).
Is my file uploaded anywhere?
No. Everything runs in your browser. Your files never leave your device, and there is no server component for this tool.
Tools that pair well with cURL to Code Converter
- JSON to TypeScript Converter json → typescript interface, free and in your browser.
- JSON Formatter format & validate json, free and in your browser.
- URL Encoder percent-encode text, free and in your browser.
- CORS Tester diagnose why a request is blocked, free and in your browser.