Skip to main content
WizTools123
WizTools123
Free Online Tools

Tool Categories


Developer Tools New Tool

Free Online Web Font CSS Generator for @font-face Blocks

Write the @font-face blocks and the matching font-family stack for a self hosted web font. Add each weight and style with its file name, choose font-display, set a unicode-range subset and fallback metric overrides, and take the preload link too. No font is uploaded or fetched here.

Free Forever Nothing Uploaded @font-face and preload No font is uploaded
Free Online Web Font CSS Generator for @font-face Blocks
Share this tool
Advertisement Slot (Top Banner) Google AdSense Unit • Responsive Banner
Web Font CSS Generator Everything happens in this tab. Nothing you paste is sent anywhere.
Preview

Handgloves quickly vexed the brazen judge.

The quick brown fox jumps over the lazy dog, 0123456789.

This preview uses a system font stack. Your font file is never loaded here, so treat the sample as a check on size, weight and line length, not on the shape of the letters.

Preload for the critical font

CSS
Family
Faces
Loading

Subset
Fallback metrics not set not set not set
Stack and preview 20px
Buy Us A Coffee

Enjoying WizTools123? Help keep our server infrastructure 100% free and open for everyone.

Buy Us A Coffee
Sponsored Content (Below Tool) Google AdSense Placement

Where each piece goes

The order matters more than the values.

The preload link belongs in the <head>, before the stylesheet that references the font, and it should name one file: the weight used by your first screen of text. Preloading four weights is a common mistake, because each one competes with the CSS and with the image at the top of the page.

The @font-face blocks go at the top of your stylesheet, or in a small file of their own that loads first. They declare nothing visible on their own; a browser downloads a face only when something on the page actually asks for that family at that weight, which is why an unused weight in your CSS costs nothing until it is referenced.

The font-family stack is what applies the font. Keep the fallback in it even after the web font works, because the fallback is what people see during the swap period and on the request that fails. A stack that ends in a bare generic family such as sans-serif always has a last resort.

How to Write @font-face CSS

A few steps, and nothing is uploaded.

1
Name the family and the folder The family name is what you will write in your CSS, and the folder is the path your font files sit at on your own server. Both appear exactly as typed in the output.
2
Add each weight and style One row per face: the weight, normal or italic, and the file name without an extension. Every row becomes its own @font-face block with the same family name.
3
Choose how it loads Pick a font-display value and read what it trades. Then pick which single file to preload, which should be the weight your first screen of text uses.
4
Copy the CSS The output holds the blocks, the font-family rule, and the preload link in a comment at the top. Nothing is uploaded and no font is fetched; the files are yours to put on your server.

What to Know About Loading Web Fonts

Including what font-display actually trades away.

No font is fetched, uploaded or hosted here. This page writes CSS text and nothing else. It never reads your font files, so it cannot convert a ttf to woff2, cannot subset a file, cannot check that the path you typed is correct, and cannot tell you what weights the file actually contains. Putting the files on your own server and getting the paths right is your part of the job.
font-display trades invisible text against a visible swap. With block the text is invisible for up to about three seconds while the font downloads, then appears in the right font. With swap the fallback font is painted immediately and is replaced when the web font arrives, so nothing is ever invisible but the text visibly reflows. swap is the usual answer because unreadable text is a worse failure than a jump, and because a slow connection turns block into a blank page. optional is stricter still: the font is used only if it arrives almost at once, otherwise it is left for the next page load.
size-adjust and the override descriptors do not change your font. They describe the fallback so that the fallback occupies roughly the same space as the real font, which is what removes most of the layout shift during a swap. They belong in a second @font-face block that points at a local font, not in the block for your web font, and finding the right numbers means measuring both fonts. The values here are a starting point for that measurement, not a calculated result.
This page does not read CSS back and does not validate your files. There is no import of an existing @font-face block, no variable font axis support, no font-feature-settings, and no check that the weight you typed matches the file. The preview uses a system font stack, so it shows size and line length honestly and tells you nothing at all about the shape of your letters.

Key Features & Capabilities

What this tool does, and what it deliberately does not.

One block per face A @font-face block for every weight and style, with woff2 first.
font-display explained All four values, with what each one costs written out as you pick it.
The preload line The link element for one critical font, with crossorigin included.
Subsets and metrics unicode-range presets or your own, plus size-adjust and overrides.
A stack, not just a name The font-family rule with a real system fallback behind it.
Nothing is uploaded No file is read and no request is made. The page works offline.

About the Web Font CSS Generator

Self hosting a font is three small pieces of text that are easy to get subtly wrong: an @font-face block for each weight, a font-family rule that uses them with a sensible fallback behind it, and one <link rel="preload"> for the file the first screen of text needs. The syntax is not long, but the order of the src formats matters, the font-weight in the block has to match what you later ask for, and one mistyped path fails silently into the fallback.

This page writes those three pieces from a list of faces. Add a row for each weight and style, give it a file name, and every row becomes a block sharing one family name. The loading section covers font-display with a plain statement of what each value trades, because that single descriptor decides whether a visitor on a slow connection sees no text or the wrong text, and the two are not equally bad. The subset and metric sections are there for the cases that need them and are left out of the output when they are not set.

It is worth being clear about the limits. Nothing is uploaded, no font file is read, and no conversion or subsetting happens, so the tool cannot tell you whether the file at that path exists or which weights it contains. The preview is deliberately honest about this too: it renders the sample in a system font stack so you can judge size and line length, and it says on the page that the letters you are looking at are not your font.

Frequently Asked Questions

Formats, display values, preload, subsets and metric overrides.

woff2 alone covers every browser in current use, and it compresses better than anything else, so a single woff2 per face is the normal answer. The woff switch here exists for the rare case of a very old browser on an internal system; if you turn it on, woff2 must still be listed first, because the browser takes the first format it understands. ttf and eot are no longer worth shipping.

How long the browser is prepared to show nothing. block hides the text for up to around three seconds hoping the font arrives, which on a slow connection means a blank page. swap paints the fallback immediately and replaces it when the font loads, so text is always readable but visibly shifts. fallback is a short block period then a swap, and optional uses the font only if it is almost instant. Choose swap unless you have a specific reason not to.

Usually because too many files are preloaded, or the link is missing crossorigin. A preload without that attribute fetches the font on a different connection from the one the CSS will use, so the file is downloaded twice. Preload exactly one file, the weight your headline and first paragraph need, and let the rest load normally.

Only if you have split your font into subsets. The descriptor tells the browser which characters a file covers, so it can skip downloading a Cyrillic subset for an English page. It does not create the subset: you still have to produce those files with a tool such as a font subsetter, and this page only writes the range into the block.

By measuring. Render the same text in your web font and in the fallback at the same size, compare the x-height or the width of a line, and adjust until they match closely. The aim is for the fallback to take up the same room, so the swap does not move anything. This tool gives you a slider to write the value into a block, not a calculation, since it never sees either font.

Other Developer Tools

Advertisement Slot (Bottom Banner) Google AdSense Unit • Responsive Banner