📡 Curl 转代码Curl to Code
把 curl 命令转为 JavaScript fetch 或 Python requests 代码:按 shell 规则解析引号,支持 -X、-H、-d、--data-urlencode、--json、-F、-u、-G、-b、-A、-I 等。本地处理。Translate a curl command into JavaScript fetch or Python requests code: quotes are parsed like a shell, with -X, -H, -d, --data-urlencode, --json, -F, -u, -G, -b, -A, -I and more. Processed locally.
使用说明与常见问题How-to & FAQ
「Curl 转代码」是什么?What is the Curl to Code tool?
把 curl 命令转为 JavaScript fetch 或 Python requests 代码:按 shell 规则解析引号,支持 -X、-H、-d、--data-urlencode、--json、-F、-u、-G、-b、-A、-I 等。本地处理。Translate a curl command into JavaScript fetch or Python requests code: quotes are parsed like a shell, with -X, -H, -d, --data-urlencode, --json, -F, -u, -G, -b, -A, -I and more. Processed locally.
如何使用「Curl 转代码」?How do I use the Curl to Code tool?
在「Curl 转代码」中,按需设置「语言」等选项,然后点击「转换」按钮即可。In the Curl to Code: Set "Language", then click "Convert".
支持哪些 curl 选项?Which curl options are supported?
请求方法 -X(含 -XPOST 写法)、请求头 -H、数据 -d/--data/--data-raw/--data-binary(多个 -d 用 & 连接)、--data-urlencode、--json、表单 -F、认证 -u、-G(把数据放进 URL)、Cookie -b、-A、-e、-I(HEAD)。-L、-k、--compressed 会以注释说明对应写法;不认识的选项会在代码顶部列出。Method -X (including the -XPOST form), headers -H, data -d/--data/--data-raw/--data-binary (several -d are joined with &), --data-urlencode, --json, form fields -F, auth -u, -G (data moved into the URL), cookies -b, -A, -e and -I (HEAD). -L, -k and --compressed become explanatory comments; unrecognised options are listed at the top of the code.
引号和换行怎么处理?How are quotes and line breaks handled?
按 bash 规则:单引号内原样保留,双引号内可用 \" 转义,支持 $'…' 写法,行尾的反斜杠表示续行。引号没闭合时会报错,而不是猜测。Like bash: single quotes are taken literally, double quotes allow \" escapes, $'…' strings are supported, and a backslash at the end of a line continues the command. An unclosed quote is reported as an error instead of being guessed.
切换语言需要重新点转换吗?Do I need to convert again after switching language?
不需要。切换 fetch / Python 后会立即按同一条命令重新生成。No. Switching between fetch and Python regenerates the code from the same command straight away.
有哪些选项可以调整?What options can I adjust?
「Curl 转代码」的设置:「语言」可选 JavaScript fetch、Python requests(默认 JavaScript fetch)。每次生成结果都按当前设置处理。Settings in the Curl to Code — "Language": JavaScript fetch, Python requests (default JavaScript fetch). The result always uses the current settings.
代码或数据会被上传吗?Is my code or data uploaded?
不会。「Curl 转代码」完全用 JavaScript 在本地运行,适合处理含有密钥、内部接口等敏感内容的数据。No. The Curl to Code runs entirely in local JavaScript, so it is safe for data containing keys or internal endpoints.
「Curl 转代码」免费吗?需要注册吗?Is the Curl to Code free? Do I need an account?
「Curl 转代码」完全免费,无需注册或安装,打开网页即可使用,手机和电脑都能用;输入的内容只在你的浏览器本地处理。The Curl to Code is completely free with no sign-up or install and works on phones and desktops; what you enter is processed only in your browser.