Nodes/Lite Text to File Tools/Load From JSON File
ComfyUI Node

Load From JSON File

Read a JSON file back as a string, three ways

By JasonHoku·Created 7 months ago·Updated 6 months ago· 2
Load From JSON File
    • json_content
    file_prefixtext/lite-text.json
    output_formatpretty

    The other JSON nodes in this pack are precise instruments - get this key, pull that index. Load From JSON File is the blunt one: it reads a whole JSON file and hands you the entire thing as a string, in whatever formatting you want. It's the fastest way to get a config file or a saved result set back into your graph when you don't care about cherry-picking fields yet.

    It's part of JasonHoku's Lite Text to File Tools pack, and it complements the write side perfectly: Save Text Into JSON and the array builders put data on disk, this node drags it back out as one blob you can dump into a Show Text node, an LLM, or a text-processing chain.

    How it works

    Two inputs. file_prefix is the path relative to ComfyUI/output/ (default text/lite-text.json). output_format is the dropdown that makes this node interesting, with three choices:

    • pretty (default) - json.dumps with 2-space indentation. What you actually want for reading.
    • compact - the whole file on one line, no whitespace. Good if the string is going into a parser or a JSON-valued prompt that hates stray whitespace.
    • array_items - only meaningful when the file holds a JSON array: each item becomes a line in the output, so a 50-item array becomes a 50-line string. For non-array data it just stringifies the value.

    The single json_content output is a plain STRING, ready to wire anywhere. Note this node is not an output node, which just means it's a data source - wire its output onward and it participates normally.

    The usual gotchas

    • Invalid JSON in the file → you get an error string out: Error: Invalid JSON - .... As with the rest of the pack, that error flows downstream as a string instead of failing the graph, so an unreadable file quietly pollutes whatever you feed the result into.
    • Missing fileError: File not found at ... as the output, same soft-failure pattern.
    • array_items on an object - it just prints the object. Fine, but if you were expecting per-value lines, you grabbed the wrong format.

    Installing it

    It ships in the Lite Text to File Tools pack:

    cd ComfyUI/custom_nodes/
    git clone https://github.com/JasonHoku/comfyui-lite-text-to-file-tools
    # restart ComfyUI
    

    Or use ComfyUI Manager and search "Lite Text to File Tools". Pure standard library - no pip deps, no models.

    Where it fits

    Load a settings file into a Show Text node to eyeball it mid-run, or pull a saved array into a text-processing node to parse. If you need one field out of a key-value file, the pack's Load Text From JSON From Key is the sharper tool; this one is for when "give me the whole file" is exactly what you mean.

    Categorylite-text-to-file

    Inputs (2)

    NameTypeDefaultDescription
    file_prefixSTRINGtext/lite-text.json
    output_formatCOMBOpretty3 options: pretty, compact, array_items

    Outputs (1)

    NameTypeDescription
    json_contentSTRING