sivin.dev
by sivin 00:00:00

← All toolsDev

Curl ↔ Fetch

Paste a curl command and get a clean, ready-to-run JavaScript fetch() snippet, with the method, headers and body wired up for you.

fetch()
const res = await fetch("https://api.example.com/users", {
  method: 'POST',
  headers: {
    'Content-Type': "application/json",
    'Authorization': "Bearer token123"
  },
  body: "{\"name\":\"Jane Doe\",\"role\":\"admin\"}",
})
const data = await res.json()

More Dev tools