Convert Fonts to Base64 Data URI CSS
Encode WOFF2, WOFF, TTF, or OTF binaries into ready-to-paste data:font/woff2;base64,... @font-face CSS — with optional HarfBuzz subsetting first to keep inline payloads tiny.
.woff2 · .woff · .ttf · .otf
- Optional subset before encode
- data:font/woff2;base64 CSS
- Single-file HTML ready
Benchmark & Expected Output
51 KB → 68 KB Data URI CSSBefore (Input)
WOFF2 · inter-regular.woff2 (51 KB)
After (Output)
Base64 @font-face CSS · data:font/woff2;base64,... wrapped in @font-face CSS
| Property | Source: WOFF2 | Target: Base64 Data URI |
|---|---|---|
| File extension | .woff2 | .css |
| Compression | Brotli (entropy + table transform) | Uncompressed SFNT |
| Outline / Curve | Quadratic or Cubic SFNT | CSS / Data URI Text |
| Browser support | All Modern Browsers (97%+) | Universal (Web + OS) |
| OpenType GSUB/GPOS | Yes | Yes |
| Best for | Production web typography across all modern browsers, delivering 40%–60% smaller payloads than TTF/OTF and ~30% smaller files than WOFF 1.0. | Single-file HTML deliverables, offline WebView bundles, Chrome extensions, and critical tiny subsetted icon/headline fonts. |
How it works
How to use Font to Base64 locally in your browser
Embed fonts as Base64 Data URIs in CSS, with optional HarfBuzz subsetting first to crush the 33% overhead.
Load font file
Drop any WOFF2, WOFF, TTF, or OTF font.
Subset before encode (recommended)
Enable pre-subsetting and enter your exact text to shrink a 100 KB font down to ~6 KB first.
Copy Data URI CSS
Copy or download the self-contained @font-face CSS snippet.
FAQ
Frequently asked questions
Why does Base64 increase font size by 33%?
Base64 turns every 3 binary bytes into 4 ASCII characters. Pre-subsetting unused glyphs first keeps embedded CSS tiny.
When should I use Base64 font CSS?
Use Base64 Data URIs for single-file HTML bundles, Chrome extensions, offline emails, or tiny sub-10 KB icon/headline subsets.
Does Font to Base64 work on TTF inputs directly?
Yes. Choose WOFF2 output to compress TTF via Brotli before Base64 encoding.
Format specs
Next step