All tools

cURL to fetch

Paste a curl command and get equivalent JavaScript fetch() code, with headers, method and body.

JavaScript fetch()
const url = "https://api.example.com/users";
const options = {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer TOKEN"
  },
  body: "{\"name\":\"Danan\",\"role\":\"dev\"}",
};

const response = await fetch(url, options);
const data = await response.json();
console.log(data);

Handles -X, -H, -d, -u and more. Parsing happens entirely in your browser.