ComfyUI Node

Google Sheets Reader

Read your prompts from a Google Sheet — no API key, just OAuth

By lazniak·Created 2 years ago·Updated 2 years ago· 12
Google Sheets Reader
    • STRING
    spreadsheet_id
    range
    client_secrets_file/tmp/ComfyUI/custom_nodes/comfyui_google_sheets_integration/client_secret.json

    The spreadsheet becomes your prompt file

    You've got a sheet full of prompts - character variations, A/B test rows, a running list you share with a collaborator - and you'd rather ComfyUI read them straight from there than from a pile of .txt files. That's the whole job of Google Sheets Reader (GoogleSheetsReader), one of two nodes in lazniak's comfyui_google_sheets_integration pack. It pulls a range of cells out of a Google Sheet and hands them to your workflow as text.

    The nice part: this is not an API-wrapper node in the "send your prompt to a cloud model" sense. It calls the Google Sheets API - that's just the mechanism to fetch your own data - and there's no API key to paste anywhere. You authenticate once with an OAuth login, and it reads whatever spreadsheet you point it at. If you've been manually copy-pasting prompts into a CLIP Text Encode node for a batch, this is the node that ends that chore.

    How it works

    Under the hood it's a thin wrapper over the Google Sheets v4 API. On first use it reads your client_secret.json (the OAuth "Desktop app" credential from Google Cloud Console), opens a browser tab for you to authorize, and stashes the resulting token in an encrypted token.pickle in the pack's folder. After that it just calls values.get() for the range you ask for and returns every row as one comma-joined string. Results are OUTPUT_IS_LIST - the STRING output is a list, one entry per row.

    The inputs that matter

    Three strings, all required, and you only really touch two of them:

    • spreadsheet_id - the long ID in the spreadsheet's URL (docs.google.com/spreadsheets/d/<this bit>/edit).
    • range - a normal A1-style range, e.g. Sheet1!A1:B10. The author's own example, and it works.
    • client_secrets_file - path to your client_secret.json. The default points at the file sitting in the pack's own directory, which is where you should have put it, so you can usually leave it alone.

    Install

    ComfyUI Manager (search "Google Sheets Integration"), or clone it by hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/lazniak/comfyui_google_sheets_integration
    pip install google-auth-oauthlib google-auth-httplib2 google-api-python-client cryptography
    

    One trap: the pack's own README tells you to clone comfyui-google-sheets-integration (hyphens), and that URL doesn't exist - GitHub just prompts you for a username. Use the underscore version above. The README also walks through creating the OAuth credential: enable the Sheets API in Cloud Console, create a Desktop app OAuth client, download client_secret.json, and drop it in the pack folder. First run will pop a browser; log in with the Google account that owns (or has edit access to) the sheet.

    Where people get burned

    The biggest gotcha isn't install - it's that the Reader dumps the whole range at once, one string per row. If you want to generate once per prompt, you don't get that for free. The community workaround (from r/comfyui thread 1kf8nz2) is to drive the range with primitives: a STRING primitive for the column, an INT for the row with control_after_generate set to increment, joined into a cell ref like B13 and fed into the range field. One row per run, then the counter steps you to the next. Comma-joining also means a row with commas in it becomes ambiguous, so keep cells simple. And keep client_secret.json private - a credential that reaches Google is exactly the kind of thing you don't commit to a public repo. If a read fails, the error string comes back as the node's output, and the pack writes a detailed google_sheets_plugin.log in its own folder.

    One footnote: the source contains a third GoogleSheetsCleaner class, but it's not registered, so don't go hunting for it in the node menu. Reader and Writer are what you get - and for pulling shared prompts off a live sheet, the Reader is the one to keep.

    CategoryUtilities

    Inputs (3)

    NameTypeDefaultDescription
    spreadsheet_idSTRING
    rangeSTRING
    client_secrets_fileSTRING/tmp/ComfyUI/custom_nodes/comfyui_google_sheets_integration/client_secret.json

    Outputs (1)

    NameTypeDescription
    STRINGSTRING