### Animate Numbers Counting Up in After Effects

## Learn how to animate numbers counting up in After Effects with just a text layer and some expressions code- no keyframing required!

There are several different methods for animating numbers counting up in After Effects. In the past I’ve used slider controls and I’ve even used the Numbers effect (don’t do that) but the method below is by far my favorite and will soon become part of all our infographics templates.

In this post I’ll show you how to animate numbers counting up with a Text layer and NO keyframes! It’s gonna get a little nerdy but I promise it’s not too difficult to follow.

For this example we’ll animate a number from 0 to 1000 by applying this nifty expression to animate with no keyframes!

1. Create a text layer and type “1000”.

2. Hold the Alt or Option key while clicking on the stopwatch for the Text layer’s Source Text property

3. Then paste this code:

`start=parseInt(thisLayer.text.sourceText="0");`

end=parseInt(text.sourceText);

val=Math.round(easeOut(time, startTime, 4,start, end));

So what does this all mean exactly?

**start=parseInt(thisLayer.text.sourceText=”0″);**>> *You can type whatever number you want in the quotations*

**end=parseInt(text.sourceText);**>> *The “ending” number is whatever text you type for the actual text layer*

**val=Math.round(easeOut(time, startTime, 4,start, end));**>> *The last line basically says “as time elapses from the Start of the layer to a number you specify representing seconds, the number will animate from the number in quotations to the number typed in the text layer. *

You should see your text animate from 0 to a 1000 in 4 seconds. Pretty cool!!

But what if you need to add a comma to 1000?

Thanks to Nick Khoo for showing the world how to do that! You can see his method here.

Below we’ve added a part of his code to our expression:

`start=parseInt(thisLayer.text.sourceText="0");`

end=parseInt(text.sourceText);

val=Math.round(easeOut(time, startTime, 2,start, end));

s=""+ val;

if (s.length > 3){

s.substr(0, s.length -3) + "," + s.substr(-3);

}else{

s

}

I know what you’re thinking…

“But but but….What about two commas?!”

A YouTuber left a comment on Nick Khoo’s video that worked that all out:

`start=parseInt(thisLayer.text.sourceText="0");`

end=parseInt(text.sourceText);

val=Math.round(easeOut(time, startTime, 2,start, end));

s=""+ val;

if (s.length > 6){

s.substr(0, s.length -6) + "," + (s.substr(1, s.length -4) + "," + s.substr(-3));

}else{

if (s.length > 3){

s.substr(0, s.length -3) + "," + s.substr(-3);

}else{

s

}}

Hopefully that little bit of code comes in handy next time you need to do the ever so boring task of animating numbers!