Nodes/ComfyUI-NegiTools/OpenAI Translate to English 🧅
ComfyUI Node

OpenAI Translate to English 🧅

For when your best prompts are in another language

By natto-maki·Created 3 years ago·Updated 2 years ago· 31
OpenAI Translate to English 🧅
    • STRING
    text_any_languagereturn "日本語の文章"

    Stable Diffusion models are trained mostly on English. If your native language isn't English, that's a real tax on every prompt you write - the model still mostly understands what you mean, but it works better, more precisely, when the prompt is in English. This node exists for exactly that: you paste text in any language, and it hands back a clean English translation as a STRING, ready to feed into a CLIP Text Encode node.

    How it works

    It sends your text_any_language to GPT-4 (the pack was written when that was the current model) with a system prompt asking for clean English output in a specific JSON shape, parses out the translated field, and returns it. Because it uses JSON response format, the output is reliably a string you can wire onward - no prose, no headers, just the translation.

    There's a nice bit of engineering in the details: the node caches the last input/output pair, so if you re-run with unchanged text it returns the cached translation instead of burning another API call. That matters, because every actual translation is a paid API call, and ComfyUI re-executes nodes more often than you'd think.

    Inputs and outputs

    • text_any_language - a multiline string in any language. (The default is literally return "日本語の文章", a leftover from the author's own usage.)
    • Output: a single STRING with the English translation.

    The README specifically calls out combining this with the pack's String Function node - and that's a genuinely good pairing. Write a template with String Function that assembles a prompt, translate the result to English with this node, and you've got a pipeline where you can think and write in your own language while the model gets exactly what it needs.

    The requirement that bites

    Like every OpenAI node in this pack, it needs OPENAI_API_KEY set in the environment before ComfyUI launches. No key, no translation - it raises an authentication error immediately. And because it's a cloud call, it only works while you're online and it costs tokens per unique input. The caching softens that, but if you're doing heavy iteration on the same text, the cache is your friend and it works.

    Installing it

    It's part of ComfyUI-NegiTools - ComfyUI Manager (search "ComfyUI-NegiTools") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/natto-maki/ComfyUI-NegiTools
    pip install -r ComfyUI-NegiTools/requirements.txt
    

    then restart with the key set.

    The honest take

    If you're a non-native English speaker doing serious prompt work, this node is quietly one of the most useful in the pack - it's a tiny habit that raises the floor on every prompt you write. The trade-off is the key and the cost. One practical tip: use it as a tool while crafting prompts, not as a per-run dependency - translate once, lock the English result into your workflow, and let the node sit idle. That way you get the quality without the per-generation bill.

    Categoryutils

    Inputs (1)

    NameTypeDefaultDescription
    text_any_languageSTRINGreturn "日本語の文章"

    Outputs (1)

    NameTypeDescription
    STRINGSTRING