Typography & font tools

Font Face CSS Generator

Upload a font file and get a ready-to-paste @font-face CSS rule, with a live editable preview so you can see exactly how it renders.

Live preview
The quick brown fox jumps over the lazy dog
Generated CSS

How to use the font face CSS generator

  1. Upload a font fileChoose a .ttf, .otf, .woff or .woff2 file from your device.
  2. Set the name, weight and styleThe family name is auto-filled from the file name; adjust it, the weight and the style as needed.
  3. Preview, copy and downloadType your own text into the preview, then copy or download the generated @font-face CSS.

How this generator works

When you upload a font file, the tool reads it locally with the FileReader API and converts it into a base64 data URI. That data URI is embedded directly inside a standard @font-face rule, alongside the format() hint matched to your file's extension. The same data URI is also registered live in your browser with the FontFace API, so the preview box below instantly renders in your actual uploaded font.

Self-contained CSS

Because the font data lives inside the CSS itself as a data URI, there's no separate font file to host or link to.

Trade-off: file size

Base64 encoding inflates the font's size by roughly a third, so embedded CSS is best for prototypes, not production.

Live FontFace registration

The same data used in the CSS is loaded through the FontFace API so you can preview it immediately, without saving anything.

Editable preview text

Click into the preview box and type your own text to see exactly how headings or body copy will look in this font.

Font Face CSS Generator FAQ

Why is the font embedded as a data URI instead of a normal file path?

Embedding the font as a base64 data URI keeps the generated CSS completely self-contained, so you can paste it anywhere without also hosting a separate font file. It's convenient for quick prototypes and demos, but it does make the CSS noticeably larger, so for a production site it's usually better to self-host the font file and reference it with a normal url() path instead.

Which font formats are supported?

TTF (TrueType), OTF (OpenType), WOFF and WOFF2. The tool detects the format from your file's extension and sets the matching format() hint automatically.

Is my font file uploaded to a server?

No. The file is read locally with the FileReader API and converted to a data URI entirely in your browser. Nothing is sent anywhere.

Can I preview my own text instead of the sample sentence?

Yes. The preview box is editable — click into it and type or paste whatever text you want to check in the uploaded font.

Try other free tools

More handy tools from My Panda Toolbox.