ComfyUI Node

isascii

The gatekeeper for old-school text

By StableLlama·Created about a year ago·Updated 4 days ago· 48
isascii
    • BOOLEAN
    string

    Some downstream tools choke on anything that isn't plain ASCII. The accented characters, the smart quotes, the emoji - all fine in ComfyUI, all a hard fail in a tool that only speaks basic text. This node is the tripwire that catches them before they bite.

    What it does

    isascii wraps str.isascii(). It returns True if every character in the string is in the 128-character ASCII set - the classic letters, digits, and punctuation - and the string is non-empty. Any accented letter, emoji, or non-Latin script makes it False.

    One string input, one BOOLEAN output. Nothing to configure.

    Why you'd reach for it

    Compatibility checks, mostly. A filename or prompt that's about to be handed to an ASCII-only parser, a legacy format, or a system that mangles Unicode - run it through isascii and branch on the result. It's also the natural partner to the pack's encode node: if you're about to encode to ascii under strict errors, this check tells you whether the encode will blow up before it does.

    In the is-* family it's the one with the most honest job: not "is this a letter" but "is this boring enough to survive an old tool."

    Installing

    Part of Basic data handling by StableLlama. In ComfyUI Manager search "Basic data handling" → Install → restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
    

    Restart. Zero runtime dependencies - pure stdlib - so the install is instant and conflict-free.

    Where people get burned

    The empty-string quirk is the one to know: isascii("") returns True, because Python treats an empty string as vacuously ASCII. That means "nothing here" passes the check - which is usually wrong for validation. If you care about "there's actually content and it's ASCII," add a length check alongside. And note it's per-character, so a string that's mostly ASCII but has one accented letter fails the whole thing - that's the point, but it's easy to be surprised by.

    CategoryBasic/STRING/is

    Inputs (1)

    NameTypeDefaultDescription
    stringSTRING

    Outputs (1)

    NameTypeDescription
    BOOLEANBOOLEAN