Free Animated Number Counter Widget for Your Website

Show your clients served, money raised or years in business as numbers that count up when visitors reach them. Copy the free code below, or describe your counters to the AI and paste two lines of HTML into WordPress, Shopify, Squarespace or Wix.

1,500+ Clients served
340 Projects delivered
27 Years in business
Format
Style

Example numbers. Switch the format, or replay the count.

Free Animated Counter Code (HTML, CSS and JavaScript)

If you are comfortable pasting code, this is a complete count-up counter with no library and no plugin. It starts each number when it scrolls into view, eases out so the count slows as it lands, formats with Intl.NumberFormat, and handles screen readers and reduced motion. Copy it into any page; it works with as many counters as you like.

<div class="stats">
  <div class="stat">
    <span class="count" data-to="1500" data-suffix="+">1,500+</span>
    <span class="label">Clients served</span>
  </div>
  <div class="stat">
    <span class="count" data-to="2500000" data-currency="USD" data-compact data-decimals="1">$2.5M</span>
    <span class="label">Donated to local causes</span>
  </div>
  <div class="stat">
    <span class="count" data-to="98" data-suffix="%">98%</span>
    <span class="label">Orders shipped on time</span>
  </div>
</div>

<style>
  .stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 2.5rem; text-align: center; }
  .count { display: inline-block; font-size: 2.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
  .label { display: block; color: #5b6168; }
  .visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
</style>

<script>
  (() => {
    const DURATION = 1500; // milliseconds
    const easeOut = (t) => 1 - Math.pow(1 - t, 3);
    const reduce = window.matchMedia('(prefers-reduced-motion: reduce)').matches;

    function format(el, value) {
      const d = el.dataset;
      const decimals = Number(d.decimals || 0);
      const opts = d.compact !== undefined
        ? { notation: 'compact', maximumFractionDigits: decimals }
        : { minimumFractionDigits: decimals, maximumFractionDigits: decimals };
      if (d.currency) Object.assign(opts, { style: 'currency', currency: d.currency });
      return (d.prefix || '') + new Intl.NumberFormat(d.locale, opts).format(value) + (d.suffix || '');
    }

    function count(el) {
      const to = Number(el.dataset.to);
      const start = performance.now();
      requestAnimationFrame(function frame(now) {
        const t = Math.min((now - start) / DURATION, 1);
        el.textContent = format(el, to * easeOut(t));
        if (t < 1) requestAnimationFrame(frame);
      });
    }

    const observer = new IntersectionObserver((entries) => {
      for (const entry of entries) {
        if (!entry.isIntersecting) continue;
        observer.unobserve(entry.target);
        count(entry.target);
      }
    }, { threshold: 0.5 });

    document.querySelectorAll('.count[data-to]').forEach((el) => {
      const final = format(el, Number(el.dataset.to));

      // Screen readers get the final value once; the moving digits are hidden.
      const sr = document.createElement('span');
      sr.className = 'visually-hidden';
      sr.textContent = final;
      el.after(sr);
      el.setAttribute('aria-hidden', 'true');

      // Reserve the final width so the count never shifts the layout.
      el.textContent = final;
      el.style.minWidth = el.offsetWidth + 'px';

      if (reduce) return; // reduced motion: keep the final number, no count
      el.textContent = format(el, 0);
      observer.observe(el);
    });
  })();
</script>

Each counter is set up with data attributes on its .count span:

AttributeWhat it does
data-toThe final number. Required. Use a plain number with no commas: 1500, not 1,500.
data-decimalsHow many decimal places to show. Defaults to 0.
data-prefix / data-suffixText before or after the number, such as + or % or " / 5".
data-currencyA currency code such as USD, EUR or GBP. The symbol and its position come from the locale.
data-compactShorten large numbers: 12000 becomes 12K, 2500000 becomes 2.5M.
data-localeForce a locale such as en-US or de-DE. Leave it out and each visitor sees their own browser format.

Put the final number as the span's text too, as in the example. Visitors without JavaScript, and anything that reads your raw HTML, then see the real figure instead of a zero.

Or build it by describing it

The code covers the counting. The design is still up to you: the cards, the colours, the icons, how the row stacks on a phone. With MightyWidgets you describe the whole stats section ("four counters on our navy background, white numbers, an icon above each") and the AI writes it. Change a number later by editing the widget, and every page that embeds it updates.

Formatting Numbers the Right Way

Most homemade counters build the number with string tricks: round it, add commas with a regular expression, stick a "K" on the end. That breaks as soon as a visitor's language writes numbers differently. Intl.NumberFormat is built into every modern browser and gets it right for each locale:

Attributesen-USde-DE
data-to="1234567.89" data-decimals="2"1,234,567.891.234.567,89
data-to="1499" data-currency="EUR"€1,4991.499 €
data-to="12000" data-compact12K12.000
data-to="2500000" data-compact data-decimals="1"2.5M2,5 Mio.

A few things worth knowing:

  • Pick a locale on purpose. Without one, each visitor sees their browser's format, which is usually what you want. If your page is in one language, set that language's locale so the number matches the text around it.
  • Compact notation is per language. German leaves thousands written out (12.000) and abbreviates millions as "Mio.". If you need "12K" everywhere, set an English locale for that counter.
  • Fix the decimal places. Setting both the minimum and maximum keeps "4.0" from showing as "4" halfway through the count, so the width stays steady.
  • Keep units in the suffix. Put "+", "%", " / 5" or " hrs" in a suffix rather than in the number, so the number stays a number.

How Long Should the Count Take?

Between one and two seconds. Shorter than about 800 milliseconds and the eye barely registers the motion; longer than two and a half seconds and people scroll past before the final number lands, which is the only part that matters.

  • Ease out. Start fast and slow down at the end (the code uses a cubic ease-out). A linear count looks mechanical, and the final digits fly past too quickly to read.
  • Use one duration for the whole row. If 27 and 1,500 both take 1.5 seconds, they land together. Speed proportional to size makes small numbers finish instantly and big ones drag.
  • Start when it is properly visible. Wait until about half the counter is on screen. Starting at the first pixel means the count is over before anyone looks.
  • Count once. A count that restarts every time someone scrolls up and down gets old fast. The demo has a Replay button for you, not as a pattern for your visitors.

Stop the Count From Shifting Your Layout

A counter going from 0 to 1,500 changes width at almost every frame: "0" is one character, "1,500+" is six. In most fonts the digits are different widths too, so even 1,111 and 1,888 are not the same size. Centred text then wobbles, and in a row the neighbouring stats get pushed around. If the row wraps, the jump can push content below it down the page, which counts toward Cumulative Layout Shift.

Two fixes, both in the free code and the demo above:

  1. Tabular figures. font-variant-numeric: tabular-nums makes every digit the same width. Most web fonts support it.
  2. Reserve the final width. Measure the number at its final value before the count starts and set that as the minimum width. The free code sets min-width; the demo layers an invisible copy of the final value under the moving one.

If your web font loads after the script runs, the measured width can be a few pixels off. Running the script after document.fonts.ready fixes that.

Counters That Work With Screen Readers

An animated number is a changing piece of text. Handled carelessly, a screen reader either reads out "zero" because that is what was there when it got to it, or, worse, announces numbers as they change if the counter sits in a live region. Neither tells anyone your stat.

  • Give screen readers the final value only. Hide the moving digits with aria-hidden="true" and put the final number in visually hidden text next to them. The label ("Clients served") stays as normal text.
  • No live regions. Do not put aria-live on a counter. Nothing about a count-up needs announcing.
  • Respect reduced motion. If prefers-reduced-motion: reduce is set, show the final numbers straight away. Turn on reduced motion in your system settings and reload this page to see the demo do it.

Use Real Numbers, and Keep Them Current

A counter makes a number look important. That cuts both ways: an inflated or stale figure looks worse in big animated digits than it would in a sentence. Some rules worth keeping:

  • Count what you can back up. "1,500 clients served" should be a number you could show someone. Round down, not up: "1,500+" for 1,537 is fair; "2,000+" is not.
  • Say when, if it changes. Money raised, members or downloads go stale. Add "as of March 2026" under the row, or a label like "this year".
  • Update by hand. A MightyWidgets counter counts to the numbers you type. It does not pull figures from your shop, your CRM or a spreadsheet. When a number changes, edit the widget and publish; the embed snippet stays the same.

Counting to a date rather than a number? That is a countdown timer, for launches, sales and events.

Rows, Cards and Formats You Can Ask For

A web page demonstrating animated number counters with examples for active users, monthly growth, and customer satisfaction.
A stats row. Three or four numbers across the page, under a hero or above a call to action. On phones they stack, or sit two by two.
A webpage showcasing flexible number formatting for animated counters, with examples for revenue, conversion rate, active users, and client growth.
Any format. Currency, decimals, percentages, "12K+", ratings out of five. Describe how each number should read and in which language.
A web page showcasing animated number counters, including stats like Happy Clients and Downloads.
Cards and icons. Each stat in its own card, with an icon, a coloured top border or a short line of detail under the label.

Prompts to Start From

Give the AI your real numbers, their labels and how they should look:

  • Agency: "Three counters on a white background: 340 projects, 27 years, 1,500+ clients. Numbers in #1f4bd8, labels in grey, and they count up when scrolled into view."
  • Charity: "One big counter showing $48,250 raised, with 'of our $60,000 goal' underneath and a progress bar below it. Add 'Updated monthly' in small text."
  • Shop: "A dark band with 12K+ customers, 4.9 / 5 average rating and 98% orders shipped on time. An icon above each, two per row on phones."
  • Clinic: "Four stat cards in German formatting: 1.250 Patienten, 15 Jahre, 98 % Zufriedenheit, 6 Fachärzte. Count up once, and no animation for reduced motion."

Adding the Counter to WordPress, Shopify, Squarespace or Wix

When you publish, MightyWidgets gives you this snippet with your widget's ID filled in. It is the same on every platform:

<script src="https://cdn.mightywidgets.com/load.js" async></script>
<div data-mightywidgets-id="YOUR_WIDGET_ID"></div>

WordPress

Add a Custom HTML block where the stats row should sit, usually below the hero or above the footer, and paste the snippet.

Shopify

In the theme editor, add a Custom Liquid section to the home page or an About page template and paste the snippet.

Squarespace

Add a Code block and paste the snippet. Squarespace runs scripts in Code blocks on its Core plan and above.

Wix

Add an Embed HTML element (Add, then Embed Code), paste the snippet and drag the box to the height of your counters.

Webflow (Code Embed element), Ghost (HTML card) and plain .html files work the same way. The counter renders inside its own Shadow DOM, so its styles will not leak into the rest of your page.

Number Counter Questions

Is the animated number counter widget free?

Yes, to start. The Free plan includes 50 credits for building and editing with AI, and your widget's first 100 loads each month are free. After that each load uses one credit; if you run out, the counter keeps working with a small "Powered by MightyWidgets" tag. The count-up code on this page is free to copy with no account at all.

Can the counter show live numbers from my shop, database or CRM?

No. The widget counts up to the numbers you give it. It does not connect to Shopify, Stripe, Google Sheets or any database. When a figure changes, edit the widget (or ask the AI) and publish, and every page that embeds it shows the new number.

When does the count start, and does it replay?

It starts when the counter scrolls into view, so people actually see it, and it runs once per page view. You can ask for it to replay every time it comes back into view, but once is usually less distracting.

Can it count down instead of up?

Yes. Ask for it to count from a higher number to a lower one, for example "seats left: count down from 50 to 12". If you want a countdown to a date and time, such as a launch or a sale ending, use a countdown timer instead.

Can I show currency, decimals or numbers like 12K+?

Yes. Say how each number should look: "$48,250", "4.9 out of 5", "12K+", "98%". The widget formats with the browser's Intl.NumberFormat, so you can also ask for a specific locale, such as German formatting with a comma for decimals.

Will the counter cause layout shift?

The count itself will not. Each number reserves the width of its final value and uses tabular figures, so the digits do not jiggle. Like any embedded widget, the counter takes up space when it loads, so if it sits above other content, give the embed div a min-height (for example style="min-height:160px") to hold its place.

Is an animated counter accessible?

It can be. Screen readers should hear the final number once, not every step of the count, and visitors who turn on reduced motion should see the final numbers straight away. Ask for both; the demo and the free code on this page do both.

I use Elementor. Do I need this?

Maybe not. Elementor, Divi and several WordPress block plugins have a counter element, and that is a fine choice on a single WordPress site. MightyWidgets helps when you want a design those elements do not offer, the same counters on several sites, or a site builder without a counter block.

Can I add icons, links or a heading to the counters?

Yes. Ask for an icon above each number, a short heading over the row, or a link under a stat ("See our projects"). It is HTML, CSS and JavaScript, so anything you can describe on a stats row is fair game.

Build Your Number Counter

Type your numbers, describe the look and paste the snippet. Free to start.

Get Started Free