What It Does
cURL to TypeScript Fetch & Axios Converter parses complex cURL command-line strings and translates them into clean, typed TypeScript fetch or Axios request functions. It accurately handles single and multiline commands, extracts HTTP methods, parses headers and Basic Auth credentials, formats JSON request bodies with 2-space indentation, and includes response error handling.
How to Use cURL to TypeScript Fetch & Axios Converter
- 1Paste your raw cURL command into the input editor or click Load Sample.
- 2Toggle between TypeScript Fetch and Axios modes to select your target library.
- 3Review the generated async function and copy the code to paste into your codebase.
Example Input & Output
curl -X POST https://api.devmaple.com/v1/projects \
-H "Content-Type: application/json" \
-H "Authorization: Bearer devmaple_token_123" \
-d '{"projectName": "Cloud Portal", "active": true}'export async function runRequest(): Promise<unknown> {
const url = "https://api.devmaple.com/v1/projects";
const options: RequestInit = {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer devmaple_token_123",
},
body: JSON.stringify({
"projectName": "Cloud Portal",
"active": true
}),
};
const response = await fetch(url, options);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
}Limitations
This tool parses standard HTTP flags (-X, -H, -u, -d, --data, --url). Advanced cURL options such as SSL certificates (--cert), socks proxies (--proxy), and multipart form file uploads (-F) are omitted to generate standard web-standard Fetch/Axios code.
Frequently Asked Questions
Does this utility support multiline cURL commands?
Yes. Backslash line continuations are parsed and normalized automatically without breaking tokens or quoted strings.
How does it handle Basic Auth (-u / --user)?
The username and password pair is converted to a standard Base64 Authorization: Basic header.
Is my cURL request or API token uploaded anywhere?
No. All parsing and code generation executes strictly inside your browser memory.
What is the difference between the Fetch and Axios output modes?
The Fetch mode uses the native browser and Node.js Fetch API with response.ok status validation and response.json() decoding, without any external dependencies. The Axios mode generates an async function using standard Axios import and options object dispatch.
Can I convert cURL commands copied directly from Chrome DevTools or Postman?
Yes. Commands copied via Chrome or Firefox DevTools ('Copy as cURL') or Postman exports paste seamlessly and parse headers, bearer tokens, and request bodies accurately.