Dev Tools
純前端檔案不上傳

cURL ↔ fetch ↔ Python 互轉

貼 cURL 指令,自動轉成 fetch / Python requests / HTTPie。支援多行 \ 續行、單雙引號。

const res = await fetch("https://api.example.com/users", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer abc123",
  },
  body: "{\"name\":\"Mark\",\"role\":\"qa\"}",
});
const data = await res.json();
如何使用
  1. 把 cURL 指令貼進左邊(支援 \ 多行續行、單引號雙引號)。
  2. 右上切目標格式:fetch(JS)、Python requestsHTTPie
  3. 右側即時產出對應程式碼,按 Copy 直接貼到你的專案。
Tips
  • 支援的 cURL flag:-X -H -d --data-raw --data-urlencode -u -A -b -G。其他無關 flag(-k -s --compressed 等)自動忽略。
  • fetch 輸出預設用 await / async,需要包在 async function 裡用。

相關工具