Overflow string."1e309" parses to Infinity, then clamps.
Symmetric. Positive and negative extremes both stay finite.
Use case. Harden user input before charts, averages, or clamps.
Compatibility
Browser & Runtime Support
_.toFinite is a Lodash 4.x Lang helper (since 4.12.0). It runs anywhere Lodash runs — modern browsers (CDN or bundle) and Node.js / Bun / Deno with npm install lodash. Native Number() does not clamp Infinity or map bad strings to 0 the same way.
✓ Stable · Lodash 4.x
_.toFinite()
Available in [email protected] full builds and the lodash/toFinite modular import. Works in evergreen browsers and current Node LTS when Lodash is installed.
100%With Lodash 4.x
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
_.toFiniteLodash 4.12+
Bottom line: Safe for production once Lodash is loaded. Prefer import toFinite from "lodash/toFinite" for smaller builds. Ideal for sanitizing form numbers, chart inputs, and math helpers that must stay finite.
Frequently Asked Questions
_.toFinite(value) converts value to a finite number. Invalid or empty-like values become 0. ±Infinity clamp to ±Number.MAX_VALUE.
toNumber can return NaN or Infinity. toFinite never returns those — it maps them to 0 or ±Number.MAX_VALUE.
toFinite keeps decimals (3.2 stays 3.2). toInteger truncates toward zero after converting (3.2 → 3).
It stays Number.MIN_VALUE (about 5e-324) — already finite, so no clamp.
No. Passing a BigInt throws (cannot convert BigInt to number). Convert explicitly first if you must.
Use import toFinite from "lodash/toFinite" or require("lodash/toFinite") for tree-shaking. Full build: import _ from "lodash" then _.toFinite.