gchq/CyberChef · error · OperationError

Unable to parse CSV: ${err}

Error message

Unable to parse CSV: ${err}

What it means

Thrown when Utils.parseCSV cannot tokenize the input as CSV using the supplied cell and row delimiters. The inner error from the parser is appended, so the message carries the concrete parse failure. It indicates the delimiter configuration does not match the input's actual structure.

Source

Thrown at src/core/operations/CSVToJSON.mjs:59

                type: "option",
                value: ["Array of dictionaries", "Array of arrays"]
            }
        ];
    }

    /**
     * @param {string} input
     * @param {Object[]} args
     * @returns {JSON}
     */
    run(input, args) {
        const [cellDelims, rowDelims, format] = args;
        let json, header;

        try {
            json = Utils.parseCSV(input, cellDelims.split(""), rowDelims.split(""));
        } catch (err) {
            throw new OperationError("Unable to parse CSV: " + err);
        }

        switch (format) {
            case "Array of dictionaries":
                header = json[0];
                return json.slice(1).map(row => {
                    const obj = {};
                    header.forEach((h, i) => {
                        obj[h] = row[i];
                    });
                    return obj;
                });
            case "Array of arrays":
            default:
                return json;
        }
    }

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Read err in the message — it names the specific tokenizer failure.
  2. Verify cellDelims/rowDelims: each is split('') so pass a single-character string (e.g. ',' and '\n' or '\r\n' won't work as one unit; use the actual separator chars).
  3. Normalize input line endings before the operation if rows are CRLF.
  4. Quote/escape fields per RFC 4180, or strip stray quotes from input.

Example fix

// before
Utils.parseCSV(input, [";"].join("").split(""), ["\r\n"].join("").split(""));
// after — use real separator characters, one char each
Utils.parseCSV(input, [";"], ["\n"]);
Defensive patterns

Strategy: validation

Validate before calling

function csvLooksValid(input, cellDelims, rowDelims) {
  if (!input || !input.length) return false;
  if (!cellDelims || !cellDelims.length || !rowDelims || !rowDelims.length) return false;
  // delimiters are split into single chars — ensure at least one row delim actually appears
  const rowChars = rowDelims.split("");
  return rowChars.some(c => input.indexOf(c) !== -1);
}

Type guard

null

Try / catch

try {
  json = Utils.parseCSV(input, cellDelims.split(""), rowDelims.split(""));
} catch (err) {
  throw new OperationError("Unable to parse CSV: " + err);
}

Prevention

When it happens

Trigger: CSVToJSON.run is called where cellDelims or rowDelims strings (split into char arrays) do not correspond to characters present in input, or the input has mixed/escaped quoting the parser cannot reconcile. Passing an empty delimiter string or delimiters that collide with quoted field content also triggers it.

Common situations: Input uses CRLF rows but only LF is configured as row delimiter; tab-separated data parsed with comma cell delimiter; delimiter strings entered as multi-character (the code splits them into single chars) causing partial matches; input containing stray quote characters.

Understand the failure class

Related errors


AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13). Data as JSON: /api/errors/58b61f8abf7eecc9. Report an issue: GitHub.