01What is Font Face Generator?
Self-hosting a web font takes three pieces of code: the @font-face rule, a way to apply it, and usually a preload hint. This generator writes all three from one form, and everything updates as you type. The @font-face rule gets your family name, a src URL with a format() hint, font-weight, font-style, font-display and an optional unicode-range. These descriptors come from the W3C's CSS Fonts Module Level 4. Pick WOFF2, WOFF, TrueType or OpenType for a single source. Or pick WOFF2 + WOFF, and the tool emits two src entries built from the same path with the extension swapped. Static fonts get one font-weight from a 100 to 900 list. Tick Variable font and you enter a minimum and maximum instead, producing a range like font-weight: 100 900, so one file covers every weight. Under the rule you get a usage block. It's a :root custom property named after the family, lowercased with spaces turned into dashes, holding the font plus your fallback stack. A body selector then uses that variable. With Generate preload tag on, you also get a <link rel="preload" as="font" crossorigin> snippet for your document head. Its type attribute is the registered media type for the format: font/woff2, font/woff, font/ttf or font/otf. For WOFF2 + WOFF it preloads only the .woff2 file, because that's the one modern browsers pick. Here's a quick example. Family Inter, path /fonts/inter.woff2, WOFF2, weight 400 and swap give a rule with src: url("/fonts/inter.woff2") format("woff2"). The usage block then declares --font-inter: "Inter", system-ui, -apple-system, sans-serif. Quotes in the family name or path are escaped, so a name with a double quote still produces valid CSS. A unicode-range entry that isn't valid syntax gets flagged under the field. Valid forms look like U+26, U+0-7F or U+4??. The spec says browsers drop an invalid unicode-range descriptor, so the warning saves you a silent failure. Some limits to keep in mind. The tool writes code only. It doesn't check that your font file exists, convert formats or subset anything. The Min Weight and Max Weight boxes accept any text, so make sure they're numbers your variable font really supports. Flagged unicode-range items are still copied into the output, so fix them before you paste. Your family names and file paths stay in this page and are never uploaded.
Front-end developers, web designers and performance engineers who host custom typefaces on their own sites. The tool runs entirely in your browser, so your data never leaves your device.
02How to use Font Face Generator
- Fill in Font Family and Source Path, for example /fonts/inter.woff2.
- Choose the Format, Font Display and Style, and edit the Fallback stack.
- Tick Variable font to enter Min Weight and Max Weight, or pick a single Weight for static files.
- Add a Unicode Range if you're serving a subset, and toggle Generate preload tag.
- Copy the Generated Code and paste the CSS and the <link> tag where they belong.
03Worked examples
- Input:
Font Family Inter, /fonts/inter.woff2, WOFF2, weight 400, swap, Generate preload tag off - Result:
@font-face { font-family: "Inter"; src: url("/fonts/inter.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; } /* Usage */ :root { --font-inter: "Inter", system-ui, -apple-system, sans-serif; } … - Truncated. The output ends with a body rule that uses the --font-inter variable.
- Input:
Font Family Brand Sans, /fonts/brand.woff2, WOFF2 + WOFF, Fallback empty, Generate preload tag on - Result:
@font-face { font-family: "Brand Sans"; src: url("/fonts/brand.woff2") format("woff2"), url("/fonts/brand.woff") format("woff"); … } … --font-brand-sans: "Brand Sans"; … <link rel="preload" href="/fonts/brand.woff2" as="font" type="font/woff2" crossorigin="anonymous" /> - Shortened. With WOFF2 + WOFF the .woff path comes from the file name, and only the .woff2 file is preloaded.
- Input:
Inter, /fonts/inter-var.woff2, Variable font on (Min Weight 100, Max Weight 900), Unicode Range U+0000-00FF - Result:
@font-face { font-family: "Inter"; src: url("/fonts/inter-var.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; unicode-range: U+0000-00FF; } … - A variable font declares a weight range rather than a single weight.
- Input:
Unicode Range: U+0-7F, U+4??, 0041, U+1F600 - Result:
Invalid item flagged: 0041 - Every range item needs the U+ prefix. Wildcards such as U+4?? are valid.
- Input:
Font Family Lora, /fonts/lora-italic.ttf, TrueType, weight 700, Style italic, Font Display optional, Fallback Georgia, serif, preload on - Result:
@font-face { font-family: "Lora"; src: url("/fonts/lora-italic.ttf") format("truetype"); font-weight: 700; font-style: italic; font-display: optional; } … --font-lora: "Lora", Georgia, serif; … type="font/ttf" - Shortened. TrueType uses format("truetype") in CSS but font/ttf as the preload media type.
- Input:
Font Family My "Display" Font, other fields default - Result:
font-family: "My \"Display\" Font"; … --font-my-display-font: "My \"Display\" Font", system-ui, -apple-system, sans-serif; - Shortened. Quotes are escaped inside the CSS string, and runs of other characters collapse to one dash in the variable name.
04Common use cases
- Moving from the Google Fonts CDN to self-hosted Inter files for privacy or performance reasons
- Adding a brand typeface to a Next.js, Astro or plain HTML site from files in /public/fonts
- Setting up a variable font so headings and body text share one download
- Splitting a font into Latin and Cyrillic subsets with unicode-range so pages only download what they need
- Writing a second @font-face rule for the italic file of a family, with font-style: italic
- Checking a unicode-range list copied from an old stylesheet before reusing it
05Tips
- Preload only the one or two fonts used above the fold; preloading every weight competes with more important requests.
- Keep crossorigin on font preloads even for same-origin files, or the browser fetches the font twice.
- TrueType and OpenType files are uncompressed, so the same font as WOFF2 is noticeably smaller; convert before shipping if you can.
- font-display: swap avoids invisible text but can cause layout shift; optional is the better choice when you'd rather skip the web font on slow connections.
06Related concepts
@font-face, font-display, Variable fonts, WOFF2, Preload, unicode-range.
Frequently Asked Questions
What is Font Face Generator?
Font Face Generator is a free, browser-based developer tool on AIDToolStack. Generate @font-face CSS rules It requires no installation or sign-up and works entirely in your browser.
Is Font Face Generator free to use?
Yes. No sign-up, no fees and no usage cap.
Does Font Face Generator store my data?
No. It runs in your browser; nothing is uploaded.