After Effects Typewriter Effect Using Expressions
Creating a type-on text animation using expressions in Adobe After Effects offers greater procedural control and automation than traditional text animators or manual keyframing. This guide covers how to implement a customizable typewriter effect using simple ExtendScript/JavaScript expressions on the Source Text property, customize typing speed with Slider Controls, and append an authentic blinking cursor.
Step 1: Create the Text Layer
- Select the Horizontal Type Tool (Ctrl+T / Cmd+T) in After Effects.
- Click in the Composition panel and type out the complete text you want to animate.
- Open the layer's properties in the Timeline panel to locate the Text > Source Text property.
Step 2: Add a Slider Control
Using an Expression Control slider allows you to control the typing animation with keyframes:
- Select the text layer.
- Go to the top menu and select Effect > Expression Controls > Slider Control.
- Rename the slider effect to
Typewriter Control(or leave it asSlider Control).
Step 3: Apply the Typewriter Expression
- Hold Alt (Windows) or Option (Mac) and click the stopwatch icon next to Source Text.
- Paste the following expression into the expression field:
slider = effect("Slider Control")("Slider");
charCount = Math.round(slider);
value.substr(0, charCount);- To animate the text:
- Move the playhead to your starting frame and set a keyframe on the
Slider Control with a value of
0. - Move the playhead forward to where you want the typing to finish, and set the slider value to the total number of characters in your text (or a high number that exceeds the length of your text).
- Move the playhead to your starting frame and set a keyframe on the
Slider Control with a value of
Step 4: Add an Automatic Blinking Cursor (Optional)
To create an automatic typewriter effect that includes a blinking
vertical cursor (|) without needing keyframes, replace the
Source Text expression with this script:
typeSpeed = 15; // Characters per second
blinkRate = 3; // Blinks per second
cursorChar = "|";
// Calculate character count based on composition time
chars = Math.floor(time * typeSpeed);
cursorBlink = Math.floor(time * blinkRate) % 2 == 0;
if (chars < value.length) {
// While typing: show text up to current frame + active cursor
value.substr(0, chars) + cursorChar;
} else {
// After typing: show full text + blinking cursor
value + (cursorBlink ? cursorChar : " ");
}Expression Breakdown
substr(start, length): A JavaScript string method that extracts a specific portion of the string, beginning at index0and displaying only the number of characters dictated by the slider or time variable.Math.floor()/Math.round(): Converts fractional time-based numbers into whole integers so letters appear one by one rather than breaking mid-character.cursorBlink: Uses the modulo operator (%) to switch the cursor visibility between on and off at a steady rhythm.