🧾 TOML 生成器TOML Generator
从 key=value 行生成合法的 TOML:自动识别数字、布尔、日期和数组,正确转义字符串,支持 [表头] 和点号键。本地处理。Build valid TOML from key=value lines: numbers, booleans, dates and arrays are detected, strings are escaped correctly, and [table] headers and dotted keys are supported. Processed locally.
使用说明与常见问题How-to & FAQ
「TOML 生成器」是什么?What is the TOML Generator tool?
从 key=value 行生成合法的 TOML:自动识别数字、布尔、日期和数组,正确转义字符串,支持 [表头] 和点号键。本地处理。Build valid TOML from key=value lines: numbers, booleans, dates and arrays are detected, strings are escaped correctly, and [table] headers and dotted keys are supported. Processed locally.
如何使用「TOML 生成器」?How do I use the TOML Generator tool?
在「TOML 生成器」中,先在上方输入或粘贴内容,然后点击「生成 TOML」、「复制」按钮即可。In the TOML Generator: Type or paste your input above, then click "Build TOML", "Copy".
支持哪些写法?What input does it understand?
每行一个 key=value。true/false(不分大小写)输出为布尔;整数、小数(.5 会写成 0.5)、0x/0o/0b、inf/nan 输出为数字;YYYY-MM-DD 和带秒的日期时间输出为 TOML 日期;[1, 2, a] 这样的方括号列表输出为数组;其余一律作为字符串并正确转义(反斜杠、引号、控制字符)。以 0 开头的数字(如 007)保留为字符串,避免变成非法 TOML。One key=value per line. true/false (any case) become booleans; integers, decimals (.5 is written as 0.5), 0x/0o/0b numbers and inf/nan become numbers; YYYY-MM-DD and date-times with seconds become TOML dates; bracket lists like [1, 2, a] become arrays; everything else is a string with backslashes, quotes and control characters escaped. Numbers with a leading zero (such as 007) stay strings, because they are not valid TOML numbers.
引号和注释怎么处理?How are quotes and comments handled?
值如果用 "…" 包住,会按 TOML 基本字符串解析转义(\n、\t、\", \uXXXX 等;无法识别的反斜杠按原样保留);用 '…' 包住则按字面保留。没有引号时,前面有空格的 # 及其后内容视为注释并去掉(如 v=1 # 说明);想保留 # 请给值加引号。以 # 开头的整行是注释,不会输出。A value wrapped in "…" is parsed as a TOML basic string (\n, \t, \", \uXXXX and so on; an unknown backslash is kept as is); a value in '…' is kept literally. Without quotes, a # that follows a space starts a comment and is removed (as in v=1 # note); quote the value to keep a #. Whole lines starting with # are comments and are not copied.
表和重复的键?Tables and duplicate keys?
[名称] 开始一个表,[[名称]] 开始表数组,a.b=1 这样的点号键会生成嵌套表;键名只能含字母、数字、_ 和 -,否则自动加引号。重复的键保留第一次的值,同名的表合并到一起,与已有值冲突的行会跳过,每一处都会在输出上方列出行号,保证输出始终是合法 TOML。[name] starts a table, [[name]] starts an array of tables, and dotted keys like a.b=1 create nested tables; keys with characters other than letters, digits, _ and - are quoted automatically. A duplicate key keeps its first value, repeated tables are merged, and lines that clash with an existing value are skipped. Each case is listed by line number above the output, so the output is always valid TOML.
代码或数据会被上传吗?Is my code or data uploaded?
不会。「TOML 生成器」完全用 JavaScript 在本地运行,适合处理含有密钥、内部接口等敏感内容的数据。No. The TOML Generator runs entirely in local JavaScript, so it is safe for data containing keys or internal endpoints.
「TOML 生成器」免费吗?需要注册吗?Is the TOML Generator free? Do I need an account?
「TOML 生成器」完全免费,无需注册或安装,打开网页即可使用,手机和电脑都能用;输入的内容只在你的浏览器本地处理。The TOML Generator is completely free with no sign-up or install and works on phones and desktops; what you enter is processed only in your browser.