Skip to content

Interface: ToNumberOptions

Options for toNumber.

Both switches turn OFF a leniency that is helpful for a hand-typed setting but wrong when the string’s other characters carry meaning. toDate and toDuration disable both, since a space inside 2026 08 02 is a field separator and a percent has no epoch or millisecond reading.

optional percent?: boolean

Whether a trailing percent sign divides the result by 100, so "25%" reads as 0.25. Defaults to true.

Disable it where a percentage has no meaning, so "25%" is a miss rather than a number two orders of magnitude away from what the text says.


optional separators?: boolean

Whether internal digit-group separators are stripped, so "1,000" and "1 000" read as 1000. Defaults to true.

Placement is not validated when enabled, so "1,00,0" also reads as 1000. Disable it when whitespace or a comma delimits FIELDS rather than grouping digits, because stripping them silently fuses those fields into one number.