Matrix Rain Generator

Make the Matrix digital rain effect online. Adjust fall speed, glyph set, colour and trail length, then export a video, a PNG, or a self-contained HTML file with the source. Free and runs in your browser.

Pick an animation

All 28 animations →

Canvas 2D
three.js
WebGL
CSS / DOM
Matrix Rain

Live controls

0.55
0.08
16
140

Knobs patch the running animation live. A few (marked in the code as baked-in values like particle counts) restart the preview.

Falling glyph columns — the classic translucent-wipe trail trick.

Your code runs in a sandboxed frame with no access to this page, and it is never sent to a server. three.js demos load the library from jsDelivr; the rest need nothing but the browser.

Advertisement

Generate the Matrix digital rain

The falling-glyph effect from The Matrix is one of the most copied animations on the web, and it is far simpler than it looks. There is no simulation and no particle system — just one falling character per column, and a trick with how the canvas is cleared.

The trick that makes it work

Almost every beginner attempt clears the canvas with clearRect each frame, which produces a single row of jittering characters with no trail. The real effect never clears at all. Instead it paints a nearly-transparent black rectangle over the whole canvas every frame:

ctx.fillStyle = 'rgba(3, 8, 5, 0.08)';
ctx.fillRect(0, 0, width, height);

Every previously drawn glyph gets 8% darker per frame, so the characters behind the leading edge fade out over roughly a second. That single line is the trail. The trail length control here is that alpha value: lower means longer.

Controls

  • Fall speed — rows advanced per frame. Each column also carries its own speed jitter, because columns moving in lockstep read as a descending grid rather than rain.
  • Glyph size — sets the column width too, since the columns are one character wide.
  • Character set — katakana (the original uses mirrored half-width katakana plus digits), binary, hex, or source-code punctuation.
  • Hue — the classic is green, but the whole palette rotates.
  • Rain upward — reverses gravity, which is a good sanity check that you understand the loop.

Exporting

  • Record produces a WebM video — the right choice for a wallpaper loop or a video background.
  • Save PNG captures a single frame.
  • Download .html gives you a complete, self-contained file with the source in it. Open it straight from disk, or drop it into a page as a background. It needs no build step, no bundler and no dependencies.

Read the JS panel to see the whole implementation; it is about 40 lines. Everything runs in your browser and nothing is uploaded.

Using it as a page background

The generated effect is roughly forty lines of canvas code with no dependencies, which makes it practical as a real website background rather than just a demo. A few things matter if you ship it.

Layering

Put the canvas in a fixed-position container behind your content and take it out of the accessibility tree:

<canvas id="matrix" aria-hidden="true"></canvas>
#matrix { position: fixed; inset: 0; z-index: -1; pointer-events: none; }

pointer-events: none matters — without it the canvas will swallow clicks meant for your page.

Respect reduced motion

Full-screen continuous motion is a real accessibility problem for people with vestibular disorders. Check the preference and do not start the loop if the visitor has asked for less motion:

if (matchMedia("(prefers-reduced-motion: reduce)").matches) return;

Stop work when nobody is looking

Browsers throttle requestAnimationFrame in background tabs, but the loop still costs something and can keep a laptop awake. Pause explicitly:

document.addEventListener("visibilitychange", () => {
  if (document.hidden) cancelAnimationFrame(handle);
  else handle = requestAnimationFrame(frame);
});

Performance

The whole canvas is repainted every frame — one translucent rectangle plus two fillText calls per column. At a 16px glyph size on a 1920px display that is around 120 columns, or 240 text draws a frame, which is comfortable. Cost scales with the number of columns, so a smaller glyph size is more expensive, not less. Cap the device pixel ratio at 2: a 3x buffer costs nine times the fill rate of 1x for no visible gain on glyphs this size.

Why it looks right, and the details people miss

Most reimplementations of this effect look subtly wrong, and it is almost always one of these four things.

1. Clearing the canvas

Using clearRect gives you a single row of jittering glyphs with no tail. The effect depends on never clearing: a translucent rectangle is painted over the whole canvas each frame, so previous glyphs decay instead of vanishing. The fade alpha is the trail length.

2. Columns marching in step

If every column advances at the same rate, the eye reads a descending grid rather than rain. Two independent sources of desynchronisation fix it: a per-column speed multiplier, and a reset that only fires with a small random probability once a column passes the bottom. The second is what keeps columns permanently out of phase rather than merely starting out that way.

3. A uniform-brightness head

In the film the leading character is near-white and the tail is saturated green. Drawing every glyph the same colour loses the sense of a droplet with a direction of travel. Here the head is drawn at high lightness and a second, dimmer glyph is drawn just behind it.

4. Static glyphs

Each cell should re-randomise its character as it falls, rather than carrying one letter down the screen. The original effect flickers because the glyph at a given position keeps changing while the column advances through it.

About the characters

The film used mirrored half-width katakana mixed with Latin digits and a handful of symbols — the designer reportedly scanned them from a Japanese cookbook. Because the glyphs are mirrored, no real font reproduces the originals exactly; katakana plus digits is the closest you get without a custom typeface.

Frequently Asked Questions

How does the trailing fade work?+

The canvas is never cleared. Each frame paints a nearly-transparent black rectangle over the entire canvas, so every previously drawn glyph gets slightly darker until it disappears. That is the whole trail effect - there is no stored history of past positions. The Trail length control is that transparency value: lower means the fade takes longer and tails get longer.

Can I use this as a screensaver or wallpaper?+

Use Record to capture a WebM video and set it as an animated wallpaper, or use Download .html to get a self-contained file you can open fullscreen in a browser. The HTML file has no dependencies and works offline straight from disk.

What characters did the original film use?+

Mirrored half-width katakana mixed with Latin digits and a few symbols - the designer reportedly scanned them from a Japanese cookbook. This generator defaults to katakana plus digits, and also offers binary, hexadecimal and source-code punctuation.

Can I put this behind my website content?+

Yes. Download .html gives you the complete implementation - roughly 40 lines. Drop the canvas into your page, position it absolutely behind your content with a negative z-index, and let it run. Keep the glyph size reasonably large and consider pausing it when the tab is hidden, since it repaints the whole canvas every frame.

Why do the columns fall at different speeds?+

Each column gets its own speed multiplier, and a column that reaches the bottom only resets with a small random chance per frame. Without both of those the columns march in lockstep and the effect reads as a descending grid rather than rain.

Related tools

This tool is provided for informational and educational purposes only. All processing happens in your browser — no data is sent to or stored on our servers. While we strive for accuracy, we make no warranties about the completeness or reliability of results.