StealThis .dev

Text Scramble / Matrix Decode

Text that scrambles through random characters before resolving to the final string — the classic hacker/matrix decode effect. Zero dependencies.

Open in Lab
vanilla-js typography
Targets: JS HTML

Code

Text Scramble / Matrix Decode

The classic hacker-movie text effect — characters scramble through a random pool before each letter resolves to its final value. Zero dependencies, pure vanilla JS with requestAnimationFrame.

How it works

A TextScramble class maintains a queue of characters to resolve. Each frame:

  1. For each character position, if it hasn’t resolved yet, pick a random char from the chars pool
  2. Once a character’s frame counter reaches its threshold, lock it to the final value
  3. Build the full string from resolved + scrambling characters and set el.innerHTML
chars = "!<>-_\\/[]{}—=+*^?#________";

The ________ padding biases toward blank space — slowing visible scrambling near the end for a natural feel.

Trigger modes

  • Auto-plays on load
  • Hover to re-trigger
  • Cycles through multiple phrases with a delay