Almost every "animated text" effect you see in a video is the same three-stage pipeline: split a string into animatable units, give each unit a time offset, then scrub the resulting timeline deterministically when it's time to export. The visual variety — typewriter, blur, stretch, 3D spatial — is mostly just different keyframes on top of that skeleton.
Here's how to build the skeleton with plain browser APIs.
1. Split text into graphemes, not characters
The tempting one-liner is [...text]. It splits by Unicode code point, which quietly breaks emoji with skin tones, ZWJ sequences like 👨👩👧👦, flags, and combining accents. Intl.Segmenter gives you what a reader actually perceives as one character:
function splitGraphemes(text) { const seg = new Intl.Segmenter(undefined, { granularity: 'grapheme' }); return [...seg.segment(text)].map(s => s.segment); } function render(text, container) { return splitGraphemes(text).map((g, i) => { const span = document.createElement('span'); span.className = 'glyph'; span.style.setProperty('--i', i); span.textContent = g === ' ' ? '\u00A0' : g; // don't let spaces collapse container.append(span); return span; }); } Two details that save debugging time: use a non-breaking space for whitespace so inline-block glyphs keep their width, and await document.fonts.ready before measuring anything — a late-loading webfont shifts every glyph box.
2. A timeline is just offset + duration + easing
Once every glyph has an index, the whole animation is one CSS rule:
.glyph { display: inline-block; animation: reveal 600ms cubic-bezier(.2, .7, .2, 1) both; animation-delay: calc(var(--i) * 45ms); } @keyframes reveal { from { opacity: 0; transform: translateY(0.4em) rotateX(-70deg); } to { opacity: 1; transform: none; } } both holds the start state during the delay, so glyphs don't flash before their turn. Total runtime is (n - 1) * stagger + duration — useful when you need to size an export.
Stick to transform and opacity. They stay on the compositor; animating width, top, or font-size triggers layout on every frame and will drop frames on a long headline.
3. Four effects from the same primitives
Once you have staggered glyphs, most preset effects are just a different pair of keyframes:
- Typewriter: reveal by
clip-path: inset(0 100% 0 0)withsteps()timing, rather than animating width. - Blur-in:
filter: blur(8px)→blur(0)plus opacity. Looks great, butfilteris expensive — keep it to short clips. - Stretch:
scaleY()with a slightskewX(), released with a spring-ishcubic-bezier(.2, 1.4, .4, 1). - Spatial / 3D: keep the per-glyph stagger but put
perspectiveandrotateX/translateZon the container so the whole line moves as one plane.
.typewriter .glyph { animation: wipe 300ms steps(1, end) both; animation-delay: calc(var(--i) * 90ms); } @keyframes wipe { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } } Different keyframes, identical timing model. That's why a template system can expose a dozen "effects" without a dozen implementations.
The image links to a browser tool that packages these presets — useful when you want the effect, not the plumbing.
4. Scrubbing is what makes export possible
CSS animations are fine for playback but awkward to control frame by frame. The Web Animations API gives every glyph a seekable object:
const glyphs = render(text, container); const anims = glyphs.map((el, i) => el.animate( [ { opacity: 0, transform: 'translateY(0.4em)' }, { opacity: 1, transform: 'none' } ], { duration: 600, delay: i * 45, easing: 'cubic-bezier(.2, .7, .2, 1)', fill: 'both' } ) ); function seek(t) { for (const a of anims) { a.pause(); a.currentTime = t; } } Now seek(1200) produces the exact same frame every time, on any machine. That determinism is the difference between a preview that plays and a video you can actually render.
5. Render frames at a fixed rate
Don't record a live tab and hope for 30fps. Compute each frame's timestamp, seek to it, capture, repeat:
const fps = 30, seconds = 3; for (let f = 0; f < fps * seconds; f++) { seek((f / fps) * 1000); // deterministic time await new Promise(requestAnimationFrame); // draw to canvas, then hand the frame to an encoder } From there: MediaRecorder on a canvas.captureStream() is the quick path but runs in real time; VideoEncoder (WebCodecs) or a server-side ffmpeg pass gives you frame-accurate output with a guaranteed fps. Use canvas.toBlob() / createImageBitmap for frames — toDataURL() is a serialization bottleneck at 90 frames.
If you animate SVG text instead of DOM nodes, serializing the SVG into an image per frame is another clean route, and it keeps the type vector-sharp at any resolution.
6. Things that will bite you
- Fonts: measure only after
document.fonts.ready, or kerning changes mid-render. - Compositor pressure:
will-changeon several hundred glyphs creates hundreds of layers. Add it for the animation, remove it after. - Filter + shadow: both defeat cheap compositing; prefer opacity/transform.
- Reduced motion: honor
@media (prefers-reduced-motion: reduce)and skip the stagger in the browser, even if the exported video still has it. - CJK and RTL:
Intl.Segmenterhandles segmentation, but you still need correctdirand line-breaking rules. Grapheme-aware is not the same as layout-aware.
When you want the effect, not the pipeline
Building this once is a fun weekend. Building the templates, presets, font handling, and export UX around it is a different project. TypeMotion.Art is a browser tool for kinetic typography — typewriter, blur, stretch, and spatial text presets with instant preview and video-ready output.
The useful takeaway is the shape of the pipeline: segment → stagger → seek → encode. Once those four stages are separate, adding a new effect is just writing two keyframes.
Disclosure: I work on TypeMotion.Art. Everything above is plain browser API code and works without the tool.
