countUp.js: a dependency-free counter for numbers that need to move
Animates a numerical value by counting to it
At a glance
- What is it?
- countUp.js animates a numeric value by counting to it, in either direction, with no dependencies. Here is how the class works, how to install it from npm, and where it stops being the right tool.
- Who is it for?
- Adopt countUp.js when you need a small, dependency-free counter for a dashboard, pricing page or stat block, and you want the number to arrive at a known end value. Do not adopt it when the value is live and changes continuously, or when you need a charting or data-visualisation layer.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 39 days ago.
- What is it written in?
- Mainly TypeScript, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 25, 2026, and from our analysis. They are not legal advice.
Star history
- inorganik/countUp.js8,147 ★ · -14
| Repository | 2026-09-22 | 2026-11-25 |
|---|---|---|
| inorganik/countUp.js | 8.2k | 8.1k |
-14 Stars in the last 64 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
What countUp.js actually solves
A number that appears on a page is static. A number that counts up to its final value reads as a measurement rather than a label, and that is the entire job of countUp.js. The README describes it as "a dependency-free, lightweight Javascript class that animates a numerical value by counting to it", and the package.json description repeats the same phrase. Despite the name, the README states it can count in either direction depending on the start and end values you provide, so a downward animation is a matter of passing a larger startVal than endVal.
The audience is front-end developers who need a counter inside an existing page and do not want to pull in an animation library to get it. The README lists integrations for Angular 2+, React, Svelte, Vue, WordPress, jQuery and custom elements, which tells you the maintainers expect it to be embedded in someone else's framework rather than used as a framework itself. The target can be an element id, an HTMLInputElement, an SVG text element, or a DOM element reference, so the same class covers plain divs and form fields.
How the counting mechanism is put together
The class takes a target, an endVal, and an options object. If endVal is null, the README says the number already inside the target element is used instead, which is a small but useful detail for progressive enhancement: the server can render the final figure and the script can animate to it.
Easing is where the design gets opinionated. The default easingFn is easeOutExpo, and useEasing defaults to true. The README describes "smart easing" as deferring easing so it stays visually noticeable, controlled by smartEasingThreshold (999 by default) and smartEasingAmount (333). The reasoning is that easing a count from 0 to 20 finishes so quickly that the curve is invisible, while large numbers benefit from it. The threshold lets you keep the effect where it can be seen.
For visibility-driven animation, autoAnimate uses IntersectionObserver. The README notes that the observer is broadly supported, and that versions 2.9.0 and earlier used a window on-scroll handler when enableScrollSpy was true. That is a real architectural change between minor versions, and it matters if you support very old browsers. The three scrollSpy options are marked deprecated in the options table in favour of autoAnimate, autoAnimateDelay and autoAnimateOnce.
The class also exposes lifecycle methods beyond start: pauseResume, reset, update, and onDestroy. The README says onDestroy cancels the animation, disconnects observers and clears callbacks, which is the method you want in a component teardown path.
Installing countUp.js and running a first counter
The package is published on npm as countup.js. The package.json points main at ./dist/countUp.umd.js, module at ./dist/countUp.min.js, and types at ./dist/countUp.d.ts, so both a bundler import and a UMD script tag are supported. Install it with:
npm install countup.jsThen import the class and point it at an element id. The README gives this shape, including the error check, which is worth keeping because the constructor sets an error property rather than throwing:
const countUp = new CountUp('targetId', 5234);
if (!countUp.error) {
countUp.start();
} else {
console.error(countUp.error);
}Options go in the third argument. The README shows passing an options object and a complete callback like this:
const countUp = new CountUp('targetId', 5234, options);const countUp = new CountUp('targetId', 5234, { onCompleteCallback: someMethod });
// or (passing fn to start will override options.onCompleteCallback)
countUp.start(someMethod);
// or
countUp.start(() => console.log('Complete!'));For animation that begins when the element scrolls into view, the README says to initialize with autoAnimate and not call start() at all:
const countUp = new CountUp('targetId', 989, { autoAnimate: true });The update method changes the end value and animates again, and pauseResume toggles between paused and running.
Where countUp.js is the wrong choice
The library animates one number to one end value. If your figure is a live metric that ticks every second, countUp.js is not a data-binding layer: you would be calling update repeatedly, and the animation duration would fight the update interval. A stream of values is better handled by writing the text directly.
The formatting options are also narrower than they first appear. useGrouping, useIndianSeparators, separator and decimal cover thousands grouping and the decimal character, and formattingFn lets you replace the whole formatter. If you need the browser's Intl.NumberFormat behaviour, formattingFn is the hook for supplying it.
A screen reader encountering an element whose text changes many times per second may announce intermediate values, and none of the documented options is an aria-live or reduced-motion setting. If your page must respect prefers-reduced-motion, check how you will handle it before relying on the counter.
Finally, the deprecated scrollSpy options are still listed in the options table. Code written against 2.9.0 and earlier may still pass enableScrollSpy, scrollSpyDelay or scrollSpyOnce, and the options table gives no removal version for them. That is an upgrade risk to track rather than a bug.
countUp.js compared with a general animation library
The obvious alternative is an animation library such as GSAP or a framework's own transition system. The difference is scope. Those tools animate arbitrary properties over time and can drive a number through a tween on an object property, but you then own the formatting, the rounding and the DOM write on every frame. countUp.js inverts that: it owns the number formatting, the grouping separator, the decimal character, the numeral substitution and the final text, and exposes only the animation curve through easingFn.
That makes countUp.js the smaller dependency and the narrower one. If you already ship GSAP for other effects, adding countUp.js is a second animation path in the same page. If you ship neither, countUp.js is the lighter addition, and it has no runtime dependencies at all according to the README.
There is also a plugin path inside the project itself. The README describes a CountUpPlugin option and names the Odometer plugin as the current example, which lets you swap the visual treatment without leaving the class. For most teams the plain counter is enough, and the plugin interface is the escape hatch when it is not.
Maintenance, licence and upgrade cost
The repository is not archived, and the last push was on 2026-10-17, and the latest release, 2.10.1, came out on 2026-07-02. The two releases before that were v2.10.0 on 2026-03-04 and v2.9.0 on 2025-06-02, so the cadence is a few releases a year rather than continuous churn. The project is MIT licensed, which permits commercial use and modification provided the copyright notice and permission notice are retained; that is a summary of the licence identifier, not legal advice, and you should read LICENSE.md in the repository before relying on it.
The friction in upgrading sits in two places. First, the deprecation of the scrollSpy options in favour of autoAnimate means older integration code needs editing. Second, the switch from a window scroll handler to IntersectionObserver, which the README places after v2.9.0 (v2.9.0 and earlier use the on-scroll handler), changes behaviour on browsers without observer support. Both are one-time edits, but they are edits you should plan for rather than discover. The build itself is TypeScript compiled with tsc and bundled with rollup, and tests run through jest, so contributing a fix follows a conventional toolchain.
Editorial conclusion
Adopt countUp.js when you need a small, dependency-free counter for a dashboard, pricing page or stat block, and you want the number to arrive at a known end value. Do not adopt it when the value is live and changes continuously, or when you need a charting or data-visualisation layer. Before you commit, verify the option names against the version you install, check that autoAnimate's IntersectionObserver behaviour matches your browser support target, and confirm which of the deprecated scrollSpy keys your codebase still uses.
Frequently asked questions
What is countUp.js?
It is a dependency-free JavaScript class that animates a numerical value by counting to it, published on npm as countup.js under the MIT licence. Despite the name, the README says it can count in either direction depending on the start and end values you pass.
How do I use countUp.js?
Create a CountUp instance with a target id and an end value, then call start(). The README's example checks countUp.error before starting, because the constructor sets an error property instead of throwing.
How do I install countUp.js from npm?
The package name on npm is countup.js. The package.json exposes a UMD build as main, an ES module as module, and TypeScript types as types, so it works with a bundler import or a plain script tag.
Can countUp.js start the animation when the element scrolls into view?
Yes. Set autoAnimate to true and do not call start(). The README notes that autoAnimate uses IntersectionObserver, while v2.9.0 and earlier used a window on-scroll handler when enableScrollSpy was true.
Can countUp.js count down instead of up?
Yes. The README states that CountUp can count in either direction, depending on the startVal and endVal you provide, so a larger start value produces a downward animation.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/inorganik-countup-js)Star history chart for your README
[](https://hysenlabs.com/projects/inorganik-countup-js)Was this useful?