Sone — A layout engine for image generation in JavaScript.

5 min read Original article ↗

Sone

A layout engine for image generation in JavaScript. Compose images like you write components.

Get startedGitHub

Built for real-world document generation

HTML and CSS were built for the web — not for programmatic mass document generation. Sone gives you a typed, declarative API tailored for its rendering engine. No missing specs. No browser overhead.

Multi-page PDF

Automatic page breaking, repeating headers and footers, page margins. Pages are just layout.

Rich text first-class

Mixed-style spans, justification, decorations, drop shadows, and per-glyph gradients in a single Text node.

Bidirectional & multilingual

Automatic RTL detection for Arabic, Hebrew, mixed paragraphs. Custom font loading for any script.

Hyphenation in 80+ languages

Automatic syllable-aware word hyphenation via Knuth–Liang patterns. Composes with balanced wrap.

Flexbox & CSS Grid

Powered by yoga-layout — the same engine behind React Native. If you know CSS, you already know Sone.

Output anywhere

Render to PNG, JPG, WebP, PDF, SVG, or raw Canvas. Same node tree, six formats.

No browser, no Puppeteer

Native Skia bindings. Images render in single-digit milliseconds, multi-page PDFs in tens of milliseconds.

Just JavaScript

No JSX, no HTML, no transpiler. Plain function calls that work in Node.js, Deno, Bun, and the browser.

YOLO / COCO datasets

Tag any node and export the full layout as a YOLO or COCO bounding-box dataset for ML training.

Just JavaScript. No JSX, no HTML.

Plain function calls that work anywhere JavaScript runs. Compose nodes like Column, Row, Text, Photo — Sone figures out where everything goes.

For Tailwind users

If you know Tailwind, you already know Sone

Same vocabulary, same flexbox model — just method calls instead of class strings. The card on the left and the card on the right render to identical pixels.

Want the full method list? Browse the layout reference →

Code in, document out

Every snippet below was rendered by Sone into the image beside it. Same builders, no JSX, no CSS — composing nodes is the entire API.

Open Graph image

Fixed-size 1200×630 social card. Same node tree renders to PNG, JPG, or WebP — single-digit-millisecond render means you can produce them per request.

OG image with hero title

Receipt with tab leaders

Tab stops with a "." leader give classic Word-style table-of-contents alignment in a single Text node — no Table needed.

Receipt with dot-leader pricing rows

Inline gradient span

Spans inside a Text inherit the paragraph layout but can override color, weight, font, decorations — even a CSS gradient color.

Heading with a gradient-colored word

Stats card with semantic spans

Two-column dashboard tile. Each delta is a Span inside the body text — color the trend without breaking out into a separate node.

Two-column stats card

Pull-quote

maxWidth + lineHeight + a decorative leading character. The author block is a sibling Column with its own typography.

Pull-quote card

Feature row

A Row of two Columns — the icon tile is just a sized Column with a background. Compose features without a CSS framework.

Icon + heading + body row

What you can build

A small sample of outputs from the test suite — click any tile to open its source on GitHub. Every image is generated programmatically — no headless browser, no HTML parsing.

Invoice

Header, line-items table, totals, and footer in one node tree.

Report

Section headings, mixed typography, charts, and signatures.

Quotation

Itemized pricing with branded header — same render as the invoice.

Bank statement

Tabular transactions with running balances and categorization.

Resume

Single-page document with mixed typography and tables.

Certificate

Centered hero typography with decorative paths.

Multi-page PDF

Auto-paginated reports with repeating headers and footers.

App UI

Render mobile app screens — perfect for store screenshots.

Tables

Colspan, rowspan, custom borders, and cell spacing.

CSS Grid

True 2D layout with explicit column and row tracks.

Lists

Ordered, unordered, and custom-marker lists with nesting.

Text styling

Mixed weights, decorations, and per-span colors.

Balanced wrapping

Lines distribute to roughly equal widths — great for headings.

Hyphenation

Knuth–Liang hyphenation for 80+ languages.

Tab leaders

Dot or dash leaders fill the gap between aligned columns.

Text orientation

Rotate text 0°/90°/180°/270° while preserving flex layout.

Bidirectional text

Mixed LTR/RTL paragraphs with auto-detected base direction.

Paths & gradients

Render any SVG path with stroke, fill, and gradient color.

Clip groups

Mask any subtree to an arbitrary SVG path shape.

Photo clipping

Decorative photo masks for hero treatments and avatars.

Text-clip image

Use text glyphs as a mask over an image fill.

Syntax highlighting

Drop-in Shiki integration via the sone/shiki entry.

How Sone compares

Sone, Takumi, Vercel Satori, and PlutoBook all turn code (or HTML/CSS) into images and PDFs, but they make different trade-offs. Pick by what you're shipping.

This table was generated with AI assistance. Some details may be outdated or wrong — check each project's docs before deciding. Spot a mistake? File an issue.

FeatureSonethis libraryTakumiRust rendererSatoriVercelPlutoBookHTML → PDF
APIPlain JS function callsJSX (HTML + CSS subset)JSX (HTML + CSS subset)HTML + CSS document
Rendererskia-canvas (native Skia)Rust + WGPU/SkiaSVG → resvg / SharpC++ + Cairo
JS / TS APIYesYesYesNode.js, C++, Python
Build step requiredNoJSXJSXNo
Image output (PNG / JPG / WebP)YesYesPNG via post-renderPNG only
PDF outputmulti-page, headers, footersNoNocore feature
SVG outputYesNonative formatNo
CSS GridYesNoNoYes
Flexbox layoutyoga-layoutYesyoga-layoutYes
Bidirectional text (RTL)auto, full UBAlimitedlimitedYes
Hyphenation80+ languagesNoNoCSS hyphens
Balanced line wrappingYesNoNoNo
Tab stops & leadersYesNoNovia CSS
Custom font loadingYesYesYesYes
Layout metadata (bboxes)YOLO / COCO exportNoNoNo
Browser runtimePNG / JPG / WebPNoPNG / SVGNo
Edge runtimeNoYesYesNo

Documents at scale

Invoices, reports, resumes, multi-page PDFs, and OG images on Node servers — first-class typography and pagination.

Edge-fast OG images

Very fast OG images and dynamic banners on edge runtimes where Rust binaries are available.

JSX-native social cards

Edge-friendly OG images with familiar JSX + CSS — the lowest-friction option if you already write React.

Print-quality PDFs

Print-perfect PDFs from existing HTML/CSS templates — Node.js, Python, and C++ bindings cover most pipelines.

Frequently asked

Common questions about what Sone solves and how it fits into a document pipeline.