A worked example, rendered from real sample data. Sign in to run the tool on your own input.
curl -X POST https://api.example.com/users -H 'Content-Type: application/json' -H 'Authorization: Bearer token123' -d '{"name":"John","email":"john@example.com"}'const response = await fetch("https://api.example.com/users", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer token123",
},
body: JSON.stringify({
"name": "John",
"email": "john@example.com"
}),
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data);
Convert cURL commands to fetch, axios, Python requests, and more. Part of the DevTools Surf developer suite. Browse more tools in the Generators collection.