ZML_文本转格式
NAI weights to SD syntax, punctuation hygiene, dedupe — ZML_文本转格式
- 文本
ZML_文本转格式 is a prompt janitor. Paste in a messy tag list - NovelAI weight syntax, broken punctuation, duplicated tags, stray underscores - and it comes out the other end clean, SDXL-ready. It's the pack's "format this prompt before it hits the encoder" node, and if you trade prompts between A1111/NovelAI and ComfyUI it will save you a ton of hand-editing.
The headline feature is NAI → SD weight conversion. NovelAI writes emphasis as {tag} (boost) and [tag] (reduce), and both SD 1.5 and the SDXL-lineage anime checkpoints expect (tag:weight). The node walks your text, counts brace depth on the { and [ runs, and converts:
- 精确 (exact) mode:
{tag}→(tag:1.1),{{tag}}→(tag:1.21),[tag]→(tag:0.9)- exponential, matching the NAI behavior - 一位小数 (one decimal) mode: linear
(tag:1.1)/(tag:1.2)style - 清空权重 strips all weight syntax entirely, leaving bare tags
The 文本格式化 dropdown handles the cosmetic passes: underscores to spaces, spaces to underscores, comma-separated tags, comma-to-newline, stripping newlines, and 括号转义 (escaping literal parens). Then 格式化标点符号 (on by default) tidies commas, periods and BREAK into SDXL-safe form - the README describes it as fixing "non-conforming punctuation." Finally, 合并相同提示词 dedupes repeated tags, with 合并白名单 protecting a comma-separated list of phrases (default BREAK) from being merged away.
Single 文本 output, plain STRING. Wire it between your prompt source and a CLIP text encode, or in front of the pack's own filter node. If you're moving an A1111 or NAI prompt into ComfyUI, this is the natural place to normalize it - the KB's prompt-engineering doc is blunt that (word:1.3) style weights are alive on the SDXL anime lineage (Illustrious, NoobAI, Pony), which is exactly the audience this node is aimed at.
Installing it
Part of ComfyUI-ZML-Image. ComfyUI Manager → search ComfyUI-ZML-Image, or:
cd ComfyUI/custom_nodes
git clone https://github.com/zml-w/ComfyUI-ZML-Image
Restart. All the conversion logic is pure Python + regex, so no models or downloads - the node's heaviest dependency is Pillow, already in ComfyUI. Chinese UI by default; English patch at https://github.com/zml-w/ZZZ_ZML_English_Patch.
Common issues
The weight conversion is the part that can surprise you. It assumes the NAI {}/[] convention and converts those; if your prompt already uses SD (tag:1.2) syntax, leave 权重转换 off or you'll get nested parens that look fine and behave wrong. The 括号转义 option exists precisely because of that collision. Also, the exact-mode math is 1.1^n and 0.9^n - a triple brace becomes 1.331, which is hot. Most people keep NAI weights to single or double braces.
Dedupe is worth testing on your own prompts before trusting it - the whitelist default (BREAK) shows the author hit the same wall you will: naive dedupe happily merges "BREAK" segments you wanted kept apart. If you see tags disappearing you wanted, that's the 合并白名单 you need to fill in.
One honest note: the UI is Chinese, and the "帮助" help text was removed from this node in an update (the README says so). If a dropdown option isn't obvious, this guide covers the four that matter.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| 文本 | STRING | — | |
| 权重转换 | COMBO | NAI转SD(精确) | 4 options: 禁用, NAI转SD(精确), NAI转SD(一位小数), 清空权重 |
| 文本格式化 | COMBO | 下划线转空格 | 7 options: 禁用, 下划线转空格, 空格转下划线, 空格隔离标签, 逗号追加换行, 清空换行, +1 |
| 格式化标点符号 | BOOLEAN | true | — |
| 合并相同提示词 | BOOLEAN | false | — |
| 合并白名单 | STRING | BREAK | 这里的提示词不会被合并,请使用逗号分隔 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| 文本 | STRING | — |