n8n-io/n8n · error · ExpressionExtensionError
cannot convert to float
Error message
cannot convert to float
What it means
toFloat() stripped currency symbols via CURRENCY_REGEXP and ran parseFloat, but the result was NaN — the remaining string had no leading numeric content at all. This is the generic conversion failure after the comma-separator case was already excluded.
Solutions
- Check the input string actually starts with a number (whitespace, letters, or symbols before the digits cause NaN)
- Pre-clean the string in a Code node: strip units, labels, and stray characters
- Use .isNumeric() or a regex test before calling toFloat() when the format is uncertain
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/@n8n/expression-runtime/src/extensions/string-extensions.ts:250 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/7e51336067d1d66d.
Report an issue: GitHub.
Appendix: source
Thrown at packages/@n8n/expression-runtime/src/extensions/string-extensions.ts:250
const [radix] = extraArgs;
const int = parseInt(value.replace(CURRENCY_REGEXP, ''), radix);
if (isNaN(int)) {
throw new ExpressionExtensionError('cannot convert to integer');
}
return int;
}
function toFloat(value: string) {
if (value.includes(',')) {
throw new ExpressionExtensionError('cannot convert to float, expected . as decimal separator');
}
const float = parseFloat(value.replace(CURRENCY_REGEXP, ''));
if (isNaN(float)) {
throw new ExpressionExtensionError('cannot convert to float');
}
return float;
}
function toNumber(value: string) {
const num = Number(value.replace(CURRENCY_REGEXP, ''));
if (isNaN(num)) {
throw new ExpressionExtensionError('cannot convert to number');
}
return num;
}
function quote(value: string, extraArgs: string[]) {
const [quoteChar = '"'] = extraArgs;
return `${quoteChar}${valueView on GitHub (pinned to 5ac6606e81)