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.

drop .woff2 / .woff / .ttf / .otf · optional pre-subsetting

.woff2 · .woff · .ttf · .otf

  • Optional subset before encode
  • data:font/woff2;base64 CSS
  • Single-file HTML ready
100% browser-localVerify 0 bytes sent in Network tab

Benchmark & Expected Output

51 KB → 68 KB Data URI CSS

Before (Input)

WOFF2 · inter-regular.woff2 (51 KB)

After (Output)

Base64 @font-face CSS · data:font/woff2;base64,... wrapped in @font-face CSS

Source vs. target font specification comparison
PropertySource: WOFF2Target: Base64 Data URI
File extension.woff2.css
CompressionBrotli (entropy + table transform)Uncompressed SFNT
Outline / CurveQuadratic or Cubic SFNTCSS / Data URI Text
Browser supportAll Modern Browsers (97%+)Universal (Web + OS)
OpenType GSUB/GPOSYesYes
Best forProduction 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.

  1. Load font file

    Drop any WOFF2, WOFF, TTF, or OTF font.

  2. Subset before encode (recommended)

    Enable pre-subsetting and enter your exact text to shrink a 100 KB font down to ~6 KB first.

  3. 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.