1,120+ npm downloads/month
Zero DOM dependency
MIT Licensed

Layout, measured.

No DOM, no guesstimates. Pure, blazing-fast JS text measurement for next-level UI.

Get StartedView on GitHub
AlexSamJordanTaylorMorgan
1.1k+

from 1.1k+ npm downloads

How It Works

ShrinkWrap.js gives you precise text measurement without touching the DOM — in four simple principles.

#1 Zero DOM Dependency

ShrinkWrap.js never touches the DOM. All measurements happen in pure JavaScript, making it safe to use in any environment — server, worker, or browser.

Zero DOM dependency illustration

#2 Blazingly Fast

Benchmarks show ShrinkWrap.js is 10–100x faster than DOM-based measurement. No layout reflow, no forced synchronous layouts, no jank.

Performance benchmark chart

#3 Universal Language Support

Full support for CJK characters, emoji, RTL scripts, and complex Unicode. ShrinkWrap.js handles every script your users write in.

Universal language support

#4 Render-Target Agnostic

Works with React, Vue, Svelte, Canvas, WebGL, React Native, and more. If you need text measurement, ShrinkWrap.js has you covered.

Render target agnostic

Benchmarks

In a suite of 10,000 measurements, ShrinkWrap.js completes in under 2ms — while DOM-based approaches take 200ms or more due to forced layout reflows.

View Full Benchmarks

Open-source, reproducible benchmarks.

Benchmark chart showing ShrinkWrap.js performance

Showcase

See what developers are building with ShrinkWrap.js — from rich text editors to data visualization tools.

GitHub
npm

Installation & Usage

Get up and running with ShrinkWrap.js in minutes. Install via npm and start measuring text with a single function call.

npm install shrinkwrapjs

Why ShrinkWrap.js?

Everything you need for precise, performant text measurement — without the hacks.

No Layout Reflow

ShrinkWrap.js never triggers a browser layout reflow. Measure thousands of strings per frame without any performance penalty.

Handles CJK & Emoji

Full Unicode support including Chinese, Japanese, Korean characters and emoji. Your international users are first-class citizens.

No Guesstimates

Unlike character-width heuristics, ShrinkWrap.js uses the actual font metrics to return exact pixel dimensions every time.

Works Everywhere

Node.js, Deno, browser, Web Worker, React Native — ShrinkWrap.js runs wherever JavaScript runs, with zero platform-specific code.

Tiny Bundle Size

Under 3KB gzipped. ShrinkWrap.js won't bloat your bundle. Ship fast, measure faster.

Simple API

One function, clear options, predictable output. Integrate ShrinkWrap.js into any project in under five minutes.

Frequently Asked Questions

Everything you need to know about ShrinkWrap.js.

Stop hacking layout.

Spend your cycles building great UI, not fighting text measurement edge cases.