I made a WebGL2 terminal renderer that hits sub-millisecond render times

77 points tjamanis 6 comments

Hey everyone,

I've been working on beamterm, a terminal renderer for web browsers. It was initially built to provide a minimal-overhead backend for Ratzilla (which runs Ratatui TUIs in the browser), but I realized it could potentially be useful as a standalone renderer for anyone building web-based terminal-like things.

What it does:

  • Renders entire terminal in a single draw call using WebGL2 instancing
  • Can handle full refresh at 45k+ cells while staying under 1ms CPU time
  • Supports Unicode, emoji, and standard text styling (bold/italic/underline)
  • Provides both Rust/WASM and JavaScript/TypeScript APIs

Technical bits:

  • Uses a 2D texture array for the font atlas (16 glyphs per layer)
  • Branchless shader pipeline for consistent performance
  • Zero allocations in the render loop
  • Direct bit manipulation for ASCII characters (skips HashMap lookups)
  • ~2.9MB total GPU memory for a 200×80 terminal with the default atlas

You can check out the live examples here - including demos from other projects using it like Ratzilla's canvas waves.

Think of it as the GPU-accelerated equivalent of rendering to an HTML canvas, but optimized specifically for terminal grids. It handles the display layer while you provide the terminal logic.

Code is MIT licensed.