Nodes/m10i/Convert CSV to JSON
ComfyUI Node

Convert CSV to JSON

CSV in, JSON out, and it will not do what you first assume

By 0nyx-networks·Created 7 months ago·Updated 4 months ago· 0
Convert CSV to JSON
    • Output JSON String
    input_string
    pretty_enabledtrue
    sort_enabledfalse

    The workflow world runs on JSON - most data-plumbing nodes, LLM nodes, and HTTP request builders want a JSON string. Meanwhile the data you're holding is often a chunk of CSV somebody pasted into a text box. Convert CSV to JSON is the adapter between those two worlds. It's dead simple, and it has exactly one behavior that will trip you up the first time.

    How it works

    The node parses the CSV with Python's standard csv.reader on the line-split input, strips whitespace from every cell, and dumps the result as JSON. The wrinkle is how it structures the output:

    • One row → a flat JSON array. a, b, c becomes ["a", "b", "c"].
    • Multiple rows → an array of arrays. Each line becomes one inner array.

    That's the part people get wrong on first contact: it does not turn a header row into object keys. Feed it name,strength over dog,0.8, and you get [["name","strength"],["dog","0.8"]] - not [{"name":"dog","strength":"0.8"}]. If you need key/value objects, that's a different (and honestly rarer) conversion; this node's contract is "CSV grid → JSON array," and it sticks to it.

    Inputs and outputs

    • input_string - your CSV, multiline.
    • pretty_enabled - default on; indents the output with 4 spaces so it's readable in a display node.
    • sort_enabled - default off. Fun detail: since the output is always an array (never an object with keys), this flag does nothing here. It's shared plumbing across the pack's converter nodes, where it matters for JSON/YAML objects. Don't hunt for a bug if flipping it changes nothing.

    The single output is Output JSON String.

    Where you'd use it

    Wire it into a text-display node to inspect the parsed structure, or hand the JSON to any downstream node that eats arrays - an LLM node, a list iterator, or a JSON mutator if you want to grow the structure before it gets consumed. It's also handy for turning a quick comma-separated list of LoRA filenames into a proper array you can loop over.

    Install

    ComfyUI Manager → search "comfy-nekonote-extensions", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/0nyx-networks/comfy-nekonote-extensions
    

    Restart ComfyUI, find it under NEKONOTE → Text. The pack is a MIT-licensed utility collection by MINETA "m10i" Hiroki (v0.4.7) with zero model downloads and no heavy dependencies - just the standard pyyaml/pillow/httpx set, most already present. Malformed CSV won't crash anything: the node returns a JSON {"error": "..."} instead. It's built on the newer comfy_api.latest backend API, so keep ComfyUI reasonably current.

    CategoryNEKONOTE/Text

    Inputs (3)

    NameTypeDefaultDescription
    input_stringSTRING
    pretty_enabledBOOLEANtrue
    sort_enabledBOOLEANfalse

    Outputs (1)

    NameTypeDescription
    Output JSON StringSTRING