cURL → fetch()
Convert cURL commands to JavaScript fetch() code. Parses -X method, -H headers, -d data, --data-raw, -u auth, and URL. Shows both Promise and async/await versions.
POSThttps://api.example.com/users2 header(s)has body
cURL command
JavaScript fetch() output
async function fetchData() {
try {
const response = await fetch("https://api.example.com/users", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer tok_abc123",
},
body: JSON.stringify({"name": "Alice", "email": "alice@example.com"}),
});
const data = await response.json();
console.log(data);
} catch (error) {
console.error("Error:", error);
}
}
fetchData();Related tools
HTTP Method TesterNetwork
Send HTTP requests to any URL and inspect the response.
HTTP Status CodesNetwork
Lookup HTTP status codes and meanings.
HTTP Headers → JSONNetwork
Convert raw HTTP headers into a JSON object.
HAR ViewerNetwork
Upload and visualize HTTP Archive (HAR) files with waterfall charts.
User-Agent ParserNetwork
Parse user-agent strings and extract browser/OS/device info.
Ace Editor Playground — In-Browser Code EditorCode
Try the Ace code editor live with syntax highlighting for 45+ languages, 24 themes, and every editor setting.