ข้ามไปยังเนื้อหา

cURL Converter — แปลง cURL เป็น fetch, Python, Go, PHP

แปลงคำสั่ง cURL เป็น JavaScript fetch, Node, Python requests, Go, PHP และ axios ดู method, query, header, cookie และ body ทำงานบนเบราว์เซอร์

ตัวอย่าง
คำสั่ง cURL

Request

POSThttps://api.example.com/v1/orders

พารามิเตอร์ query

2
expand
items
limit
20

Header

2
Content-Type
application/json
Authorization
Bearer demo_7f3a9c2e41

Cookie

2
session
7d1f0c
theme
dark

Body

JSON
{
  "customer": "cus_42",
  "items": [
    {
      "sku": "KB-75",
      "qty": 1
    }
  ],
  "note": "It's a gift"
}

ตัวเลือก

บีบอัด (--compressed)
// Browsers drop forbidden headers (Cookie, Host, Referer…).
// For cookies, use credentials: "include" instead.

// Browser manual redirects return an opaque response; the 3xx status and body are unavailable.
const response = await fetch("https://api.example.com/v1/orders?expand=items&limit=20", {
  redirect: "manual",
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer demo_7f3a9c2e41",
    "Cookie": "session=7d1f0c; theme=dark"
  },
  body: JSON.stringify({
    "customer": "cus_42",
    "items": [
      {
        "sku": "KB-75",
        "qty": 1
      }
    ],
    "note": "It's a gift"
  })
});

console.log(response.status, await response.text());

POST · 25 บรรทัด · คำเตือน: 0ไม่มีการส่งข้อมูล

ทำงานในเบราว์เซอร์ คำสั่งถูกแยกวิเคราะห์เท่านั้น ไม่มีการรันและไม่มีการส่ง request

แหล่งอ้างอิงรูปแบบไฟล์

อัปเดตหน้าเครื่องมือเมื่อ: