Nodes/GF_translate/🐵 GF JsonTranslate
ComfyUI Node

🐵 GF JsonTranslate

Batch-translate a JSON file's title fields — with a catch

By gorillaframeai·Created 2 years ago·Updated 2 years ago· 8
🐵 GF JsonTranslate
    • translated_json_path
    input_path
    source_langauto
    target_langen
    fancy_modetrue

    🐵 GF JsonTranslate is the batch sibling of GF Deep Translate in the same pack. Where that node translates whatever text you hand it, this one points at a JSON file on disk, translates the string values it cares about, and writes a translated copy next to the original under {filename}-{target_lang}.json.

    The catch first, because it decides whether this node is for you

    This node does not translate every string in your JSON. It recursively walks the whole structure - nested dicts, lists, objects inside objects - and translates only the values that live under a key literally named "title". Everything else sails through untouched. If your interesting text sits in description, caption, or any other key, this node will not touch it. That's the single most common reason someone runs it and wonders why nothing changed.

    Where it does shine: captioning and dataset tools that export JSON where each entry's human-readable text lives in a title field. Point it at that file, pick auto source and your target language, and walk away.

    How it works

    It reads the file as UTF-8 JSON, recursively collects every title string, then translates them in parallel - 25 worker threads hammering deep-translator's Google endpoint. Failures fail open: if one translation throws, the original text is kept instead of the node crashing. When it finishes, it writes the new file to the same folder as the input.

    The inputs that matter:

    • input_path - absolute path to your JSON file.
    • source_lang - defaults to auto (Google detects it).
    • target_lang - defaults to en; there's also a none option that leaves text untouched, handy if you're toggling the node on and off in a workflow.
    • fancy_mode - defaults to true, pretty-printing the output with 4-space indents. Flip it off for a compact, single-line JSON.

    Output: translated_json_path, a STRING with the path to the new file. Wire it into a show-text node to see where it landed.

    Installing it

    Same pack as GF Deep Translate - ComfyUI Manager, search "GF_translate". Or by hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/gorillaframeai/GF_translate
    

    restart ComfyUI, and let it install the single pip dependency, deep-translator. No models, no GPU, no API key - just network access to Google Translate.

    Gotchas

    If the input file doesn't exist, or won't decode as UTF-8, the node silently returns None - no error, no file, just nothing. And because everything goes through that same free Google endpoint, a batch job with lots of title fields can hit rate limits. The fail-open behavior means you might end up with a file where some strings are still in the original language and no warning anywhere. Spot-check the output before you trust it in a dataset.

    Small pack, one-file MIT codebase, no registry reputation to speak of - perfectly fine for what it does, just don't assume it does more than "title fields get translated."

    CategoryCustom

    Inputs (4)

    NameTypeDefaultDescription
    input_pathSTRING
    source_langCOMBOauto135 options: auto, afrikaans, albanian, amharic, arabic, armenian, +129
    target_langCOMBOen135 options: afrikaans, albanian, amharic, arabic, armenian, assamese, +129
    fancy_modeBOOLEANtrue

    Outputs (1)

    NameTypeDescription
    translated_json_pathSTRING