在瀏覽器中將 curl 命令轉換為等效的 JavaScript fetch 程式碼。
如何使用 cURL 轉 fetch
貼上 curl 命令。
立即生成等效的 fetch 程式碼。
將 JavaScript 複製到您的專案中。
A converter that turns a curl command into equivalent JavaScript fetch code, parsing the method, URL, headers and body so you get a ready-to-use request instead of translating it by hand.
It is a common need: API docs and tools like browser devtools give you a curl command, but your app is written in JavaScript. This bridges the two so you can paste curl and get fetch.
It runs locally in your browser, so your command, including any tokens or credentials in the headers, never leaves your device.
It understands the common flags: -X for the method, -H for headers, -d and its variants for the body, -u for basic auth, plus -A for the user agent and -b for cookies. A data flag implies POST, matching how curl behaves.
Multi-line commands work as-is. Backslash line continuations are joined automatically, so you can paste a command exactly as it appears in documentation without cleaning it up first.
The output is a fetch call with the method, headers and body filled in, which you can drop into your code and await like any other fetch.
常見問題
常用的旗標:-X 設定方法,-H 設定標頭,-d 及其變體設定請求主體,-u 設定基本驗證,以及 -A 和 -b。資料旗標暗示 POST。
不會。轉換完全在瀏覽器中執行,您的命令和其中的任何 Token 都不會離開您的裝置。
支援。反斜線續行符會自動連接,因此您可以直接貼上文件中的命令。
嵌入此工具
將此工具加入你自己的網站。複製下方的程式碼片段,它會自動保持最新。
<iframe src="https://monu.tools/embed/zh-Hant/curl-to-fetch" width="100%" height="640" style="border:1px solid #e5e5e5;border-radius:12px;max-width:680px" loading="lazy" title="Monu Tools"></iframe>相關工具