curlwtfcurlwtf

Converter

Convert curl to JavaScript

Paste any curl command and get a ready-to-run JavaScript fetch equivalent — headers, auth, JSON body, and all flags handled. Credentials use environment variables automatically.

Open curl explainer →

Example

curl input
curl -X POST https://api.openai.com/v1/chat/completions \
  -H "Authorization: Bearer sk-proj-REDACTED" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-4o","messages":[{"role":"user","content":"Hello"}]}'
JavaScript output
const response = await fetch("https://api.openai.com/v1/chat/completions", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.OPENAI_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "gpt-4o",
    messages: [{ role: "user", content: "Hello" }],
  }),
});

const data = await response.json();
console.log(data);

Also available

→ curl to Python→ curl to Go
© 2026 curlwtf