ComfyUI Node

Random Text

A random string generator with a character set you control

By alexjx·Created 10 months ago·Updated 4 months ago· 0
Random Text
    • text
    chars0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
    length10
    seed0

    Random Text generates a random string of a given length from a character set you specify. That's the whole node: chars defines what the alphabet is, length defines how long the string is, seed makes it repeatable. If you've ever needed a random alphanumeric token, a test string, or a way to inject unpredictability into a prompt-related value, this is the node.

    Let's be honest about the ceiling here: it generates random text, not meaningful text. It picks characters uniformly from whatever you give it, so with the default character set you get something like 7kQ#2x!mZ9 - useful as a unique identifier or a nonce, useless as a prompt. The node's real niche is generating tokens and keys, or acting as a source of high-entropy values inside a workflow. The default chars value is essentially every printable ASCII character, which is a big alphabet and therefore a very unguessable string for its length.

    How it works

    Mechanically simple: it seeds Python's random module with your seed, then draws length characters via random.choice(chars) and joins them. Because the seed is deterministic, the same inputs produce the same string every run - and different seeds produce entirely different strings. Set length up to 10,000 if you want a genuinely long blob; the character set is whatever string you type, so you can restrict it to digits (0123456789) for a PIN-style token or hex (0-9a-f) if that's what downstream wants.

    Inputs and outputs

    • chars - the character alphabet, as a single-line string. The default is all printable ASCII
    • length - INT, 1 to 10,000, default 10. How many characters to draw
    • seed - INT, default 0. Determinism

    The output is text, a STRING. It's a text value, so it wires into anything that takes a string - prompt concatenation, filename construction, whatever.

    Installing it

    With the rest of the XJNodes pack. ComfyUI Manager → search "ComfyUI-XJNodes" → install → restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/alexjx/ComfyUI-XJNodes
    # restart ComfyUI
    

    No dependencies. Category: XJNodes/text.

    Two things to watch

    First, the node calls random.seed(seed), which reseeds Python's global random module. In practice that mostly affects other XJNodes that share the global RNG - it's the kind of thing that can make two "independent" random nodes in one workflow produce correlated results. If you're wiring multiple random sources into the same run, it's a real (if niche) footgun. Second, empty chars throws an error, so if you're clearing the field to experiment, expect a failure rather than a fallback. And the honest framing: for semantic randomness - a random prompt, a random tag, a random artist name - the pack's Random Text From List and Random Text From File are the tools you actually want. This node is for when "random" means "entropy," not "variety."

    CategoryXJNodes/text

    Inputs (3)

    NameTypeDefaultDescription
    charsSTRING0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
    lengthINT101–10000
    seedINT00–18446744073709550000

    Outputs (1)

    NameTypeDescription
    textSTRING