EXPERIMENTAL • OPEN SOURCE

Text Layout Without the DOM

Powered by @chenglou/pretext — pure arithmetic text measurement that never triggers browser reflow. Resize the window and watch heights update in real time.

Zero Reflow Canvas Measurement Multilingual Virtualization-Ready ~2kB gzipped
prepare() time (ms)
layout() time (ms)
Cards rendered

Live Height Prediction

Type or edit the text below. Pretext calculates the exact rendered height using pure math — no hidden DOM element, no getBoundingClientRect.

Predicted height
Line count
Computation time

Masonry Card Grid

Cards with variable text lengths laid out in a masonry grid. Pretext predicts each card's height so we can position them without measuring the DOM. Resize your window to see them reflow.

Text Flow Around Images

Using layoutNextLine() to flow text around a floated image — each line gets a different available width depending on its vertical position.

Shrink-Wrap & Balanced Text

Find the tightest container width that keeps the same line count — perfect "balanced text" without CSS hacks. Drag the slider to set the desired line count.

We build HVAC contractor websites that are designed to convert, not just look good. Fast load times, mobile-first layouts, click-to-call buttons, service area pages, and structured data that Google actually understands.
Optimal width
Actual lines

Inline Objects in Text Flow

Animated pills, badges, and chips that live inside reflowing text. Each object is measured and placed using Pretext — drag the width slider and watch everything reflow together.

Objects placed
Lines
Frame time

Build with Pretext

Zero-reflow text measurement. Install from npm, deploy on Cloudflare. See the source on GitHub.