How to format numbers in After Effects?
-
- Create a text layer.
- Add a Slider Control to the text layer and rename it to Number.
- Alt-click on the Source Text property and paste the expressions below.
// slider with a number var number = parseFloat(effect("Number")("ADBE Slider Control-0001")) var multiplier = 1; // change the value to 10, 100 etc. number = number * multiplier; var prefix = "$"; // sign before the number // sign between numbers (you can put a space or comma) var separator = "."; var postfix = ""; // sign after the number var string = number.toFixed(0) + ""; "$" + string.replace(/(d)(?=(ddd)+([^d]|$))/g, '$1' + separator) + postfix;
- Create 2 keyframes on the slider with 0 and 1000000 values.
How does it work?
The expression uses a regular expression to search for the number pattern and modifies it. You can learn more about regular expressions at https://en.wikipedia.org/wiki/Regular_expression
How to make a number bigger than 1,000,000?
Change the multiplier variable to 10, 100, etc.
How to change the dollar sign?
Change the prefix variable to any symbol, word or leave it blank like this “”.
How to add a word after the number?
Change the postfix variable.