Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Micro npm Packages
  3. is-number

is-number

MITJavaScript

A JavaScript utility that reliably checks if a value is a finite number, handling edge cases like strings, NaN, and Infinity.

Visit WebsiteGitHubGitHub
285 stars53 forks0 contributors

What is is-number?

is-number is a JavaScript utility library that reliably checks whether a value is a finite number or a numeric string. It solves the problem of inconsistent number detection in JavaScript, where naive methods like `+value` or `Number()` can produce unexpected results for edge cases like empty strings, arrays, or NaN.

Target Audience

JavaScript and Node.js developers who need robust type validation for user input, parsed data, regex matches, or any scenario where distinguishing numbers from non-numbers is critical.

Value Proposition

Developers choose is-number because it provides a performant, battle-tested solution that handles JavaScript's type coercion quirks consistently, reducing bugs and simplifying validation logic compared to manual checks.

Overview

JavaScript/Node.js utility. Returns true if the value is a number or string number. Useful for checking regex match results, user input, parsed strings, etc.

Use Cases

Best For

  • Validating user input from forms or APIs to ensure numeric values
  • Checking regex match results before mathematical operations
  • Parsing and validating data from external sources like CSV or JSON
  • Writing utility functions that require strict number type guards
  • Replacing error-prone manual checks with a reliable library
  • Ensuring consistent behavior across different JavaScript environments

Not Ideal For

  • Applications that require Infinity or NaN to be treated as valid numbers (e.g., scientific computing where infinite values are meaningful)
  • Projects where minimizing dependencies is paramount and inline checks with Number.isFinite suffice
  • TypeScript projects needing built-in type guards without external type definitions
  • Environments requiring broad type validation beyond numbers, as it only handles finite number detection

Pros & Cons

Pros

Robust Edge Case Handling

Correctly identifies tricky cases like +[] and +'' as non-numbers, avoiding false positives that naive casting methods produce, as highlighted in the README's examples.

Performance Optimized

Uses .isFinite internally and is 3x-4x faster for non-string/number values compared to previous versions, with benchmarks showing competitive speeds against parseFloat.

String Number Support

Recognizes numeric strings such as '5e3' and '0xff' as valid numbers, making it ideal for parsing user input or regex matches where type coercion is common.

Consistent Across Environments

Provides predictable results across different JavaScript runtimes, reducing bugs from inconsistent type checking in browsers or Node.js.

Cons

Breaking Changes History

Version 5.0.0 removed support for instanceof checks, and v7.0.0 introduced refactors, which could disrupt projects not carefully managing dependencies or updates.

Narrow Scope

Only checks for finite numbers; lacks features for validating integers, ranges, or other types, forcing developers to use additional libraries for comprehensive validation.

No Native TypeScript Support

The README doesn't mention TypeScript definitions, requiring users to rely on community-maintained types or manual declarations, adding setup overhead.

Frequently Asked Questions

Quick Stats

Stars285
Forks53
Contributors0
Open Issues9
Last commit3 years ago
CreatedSince 2014

Tags

#number-validation#number#validation#nodejs#utility-library#is#type-checking#javascript#numeric#float#jonschlinkert

Built With

J
JavaScript
N
Node.js

Links & Resources

Website

Included in

Micro npm Packages4.6k
Auto-fetched 13 minutes ago

Related Projects

is-oddis-odd

I created this in 2014, the year I learned how to program. All of the downloads are from an old version of https://github.com/micromatch/micromatch. I've done a few other things since: https://github.com/jonschlinkert.

Stars363
Forks70
Last commit7 years ago
is-evenis-even

I created this in 2014, when I was learning how to program.

Stars266
Forks15
Last commit8 years ago
easy-math.jseasy-math.js

A tiny easy math include addition multiplication subtraction division.

Stars8
Forks1
Last commit6 years ago
my-primemy-prime

Finds prime numbers using the Sieve of Eratosthenes algorithm.

Stars2
Forks0
Last commit4 years ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub