Welcome to HTVG
HTVG (HyperText Vector Graphics) is a static compiler that transforms JSON element trees into pure, self-contained SVG with pixel-perfect text layout and full flexbox support.Quick Start
Get started in under 5 minutes with a working example
Installation
Install HTVG for Rust, Node.js, or use the CLI
API Reference
Explore the complete API documentation
Examples
Browse real-world examples and use cases
Why HTVG?
HTVG solves the challenge of generating complex, text-rich vector graphics programmatically. Unlike traditional SVG generation, HTVG provides:- Correct Text Layout - Powered by Parley for proper text shaping, line breaking, and glyph positioning
- Flexbox Layout - Full CSS Flexbox support via Taffy for responsive layouts
- Simple JSON API - Familiar element tree structure matching JSX/VDOM patterns
- Pure SVG Output - Static, self-contained SVG with no JavaScript dependencies
- WASM Compatible - Runs in browsers, Node.js, Cloudflare Workers, and edge runtimes
HTVG is perfect for generating Open Graph images, social media cards, badges, charts, and any vector graphics that require complex text layout.
How It Works
HTVG takes a JSON element tree and compiles it to SVG through a multi-stage pipeline:Simple Example
Here’s a minimal example that demonstrates HTVG’s core functionality:Core Features
Element Types
HTVG provides four fundamental element types:box
Block container element for layout and visual composition
flex
Flexbox container with full CSS Flexbox support
text
Text leaf element with automatic line wrapping and shaping
image
Image element with intrinsic dimensions and object-fit
Style Properties
HTVG supports a comprehensive set of CSS-like style properties:- Layout:
width,height,minWidth,maxWidth,minHeight,maxHeight,margin,padding - Flexbox:
flexDirection,justifyContent,alignItems,gap,flexWrap,flexGrow,flexShrink - Visual:
backgroundColor,borderWidth,borderColor,borderRadius,opacity - Typography:
fontFamily,fontSize,fontWeight,lineHeight,textAlign,color,letterSpacing - Image:
objectFit(contain,cover,fill)
Use Cases
HTVG excels at generating:- Open Graph images and social media cards
- Dynamic badges and status indicators
- Charts and data visualizations
- Email signatures and letterheads
- Programmatic diagrams and infographics
- PDF-ready vector graphics
Next Steps
Install HTVG
Choose your platform and get HTVG installed
Quick Start Guide
Build your first HTVG project in minutes