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
- Read err in the message — it names the specific tokenizer failure.
- 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).
- Normalize input line endings before the operation if rows are CRLF.
- 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
- Pass single-character delimiter strings; the API splits them into char arrays.
- Ensure the row delimiter actually occurs in the input.
- Normalize line endings (CRLF → LF) before parsing.
- Inspect the appended err to find the tokenizer's specific complaint.
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
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Unable to parse JSON to CSV: ${err.toString()}
- Invalid recipe
- Invalid marker while parsing JPEG at pos ${stream.position}:
- Unable to parse JPEG successfully
- Invalid block type while parsing DEFLATE stream at pos ${str
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/58b61f8abf7eecc9.
Report an issue: GitHub.