Universal Typeset

One line of code. Book-quality typography.

One script tag. Instant access to the same typographic rules used by book publishers and design studios.

<script src="https://typeset.us/go.js"></script>
6KBZero dependencies • Pure vanilla JS
Before & After

Without go.js

She worked in a studio on the edge of the city. It was small but it had good light and a view of the park. On clear days she could see all the way to the bridge. The tools of her trade filled every surface — ink, paper, type specimens, a loupe she kept on a chain. Everything in its place. She believed good work came from good order, and she was right about that.

With go.js

She worked in a studio on the edge of the city. It was small but it had good light and a view of the park. On clear days she could see all the way to the bridge. The tools of her trade filled every surface — ink, paper, type specimens, a loupe she kept on a chain. Everything in its place. She believed good work came from good order, and she was right about that.

What changed

  • • Short words like a, it, of bound to the next word  they never strand at a line end
  • • Last two words always stay together  no orphans
  • • Sentence starts like It was and On clear are kept as pairs
  • • Short sentence endings pulled back to the previous line
  • • CSS: text-wrap: pretty, hanging punctuation, ligatures
What it does

Orphan Prevention

Binds the last two words of paragraphs together with non-breaking spaces, preventing single words from sitting alone on the final line.

Short Word Binding

Automatically binds articles and prepositions (a, an, the, in, on, at, to, by, of, or, is, it, as, if, vs) to the following word to prevent awkward line breaks.

Sentence-Start Protection

Binds the first two words after sentence-ending punctuation to ensure sentences don't start with a single word on a new line.

Sentence-End Protection

Binds short words (1-3 characters) before punctuation to the previous word for better visual rhythm.

Text Wrap

Applies CSS text-wrap: pretty to paragraphs for balanced line lengths, and text-wrap: balance to headings for optimal centering.

Hanging Punctuation

Enables hanging-punctuation: first last on paragraphs so quotation marks and punctuation optically align with text.

OpenType Features

Activates ligatures, contextual alternates, and kerning (liga, calt, kern) for professional-grade letter spacing and connections.

Configuration

data-typeset-selector

Customize which elements get typeset. Default targets: p, li, blockquote, figcaption, h1-h6, td, th, dd, dt, label

<script src="https://typeset.us/go.js" data-typeset-selector=".article p, .content h2"></script>

data-typeset-disable

Disable specific rules. Options: orphans, short-words, sentence-start, sentence-end, text-wrap, hanging-punctuation, font-features

<script src="https://typeset.us/go.js" data-typeset-disable="orphans,short-words"></script>

data-no-typeset

Skip typesetting for specific elements or sections

<div data-no-typeset>This content won't be typeset</div>
JavaScript API

window.typeset.run(element)

Manually run typesetting on a specific element or the entire document

// Run on entire document window.typeset.run(); // Run on specific element const article = document.querySelector('.article'); window.typeset.run(article);

window.typeset.text(string)

Process a string of text and return it with typographic rules applied

const raw = "This is a sample text"; const processed = window.typeset.text(raw); console.log(processed);

window.typeset.version

Get the current version of go.js

console.log(window.typeset.version); // "1.0.0"