FileFitly

How to Use Custom Fonts on a Website (TTF to WOFF2 + CSS)

Found the perfect font and want it on your site? Here is how to use custom fonts on a website: convert to WOFF2, write the CSS, and keep the page fast.

By Anmol Sharma · Text · 8 min read · Updated November 15, 2026

How to use custom fonts on a website with WOFF2 and CSS
Quick answerCheck the font licence, convert the TTF or OTF to WOFF2 with Webfont Generator, upload the files to your site, paste the @font-face CSS it gives you, and use the font-family name with fallbacks.

Convert your font to WOFF2

Open Webfont Generator →

You found the perfect font for your brand or blog, and you want your website to use it. Installing it on your own computer is not enough: visitors only see it if the website sends the font to their browser. Do it wrong and the page loads slowly, the text flickers, or visitors simply see Arial.

This guide shows how to use custom fonts on a website properly: which font formats you need, how to convert a TTF or OTF font to WOFF2, how to write the @font-face CSS, how to keep the page fast, and how to check the licence. It works the same for a hand-coded site, WordPress or any other platform that lets you add CSS.

Three ways to put a font on a website

  1. A font service such as Google Fonts: you paste a link and the font loads from their servers. Easiest, but you depend on a third party, and some privacy rules discourage loading fonts from outside servers.
  2. Self-hosting (this guide): you upload the font files to your own site and load them with CSS. Fast, private and under your control.
  3. System fonts: use fonts already on visitors’ devices. Fastest of all, but you cannot pick a special font.

Self-hosting is the usual choice when you have a specific brand font, or want the speed and privacy of serving everything from your own domain.

The font formats you need

FormatUse
WOFF2The format for the web: smallest files, supported by all modern browsers. Use this.
WOFFOlder format for older browsers; only needed if you must support very old devices.
TTF / OTFDesktop formats for installing in Windows, macOS, Word, Photoshop. Too large for the web.
EOT, SVG fontsObsolete. Skip them.

Most fonts you download come as TTF or OTF. For a website, convert them to WOFF2.

How to use custom fonts on a website: step by step

Step 1: check the licence

Fonts are software with licences. Free fonts from Google Fonts and most open-source fonts (SIL Open Font License) allow web use. Many paid desktop fonts do not include web use, or need a separate webfont licence. Read the licence file that came with the font before you upload it.

Step 2: convert the font to WOFF2

FileFitly’s Webfont Generator converts fonts in your browser without uploading them:

  1. Add your font files. TTF, OTF, WOFF or WOFF2; add the whole family (Regular, Bold, Italic) at once.
  2. Choose the formats: WOFF2 (selected) and, only if needed, WOFF or TTF / OTF.
  3. Open More options to set the family name used in CSS, the font-display value (swap is selected), and optionally a preload line.
  4. Press Make webfont kit.
  5. Download kit (.zip) with the font files and the CSS, or Copy CSS.

Step 3: upload the files

Upload the WOFF2 files to your site, for example into a /fonts/ folder. On WordPress, a child theme’s folder or a small “custom fonts” plugin can hold them; many page builders also have an upload option for custom fonts.

Step 4: add the @font-face CSS

The kit’s CSS looks like this:

@font-face {
  font-family: "Brand Sans";
  src: url("/fonts/BrandSans-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Brand Sans";
  src: url("/fonts/BrandSans-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

Paste it into your site’s CSS (in WordPress: Appearance → Customize → Additional CSS, or your theme’s stylesheet), and check that the file paths match where you uploaded the fonts. MDN documents every option in @font-face.

Step 5: use the font

body { font-family: "Brand Sans", Arial, sans-serif; }
h1, h2, h3 { font-family: "Brand Sans", Georgia, serif; font-weight: 700; }

Always list fallback fonts after yours, so text still appears if the font fails to load.

Keep the page fast

  • WOFF2 only. It is typically far smaller than TTF.
  • Load only the weights you use. Regular and Bold are often enough; every extra weight is another download.
  • Use font-display: swap, so text appears immediately in a fallback font and switches when yours loads, instead of staying invisible.
  • Preload the main font. The kit can give you a <link rel="preload"> line for your most important font file; put it in the page’s head.
  • Do not embed big fonts in CSS. The embed in CSS option suits small icon fonts and single-page projects; for normal sites, separate files cache better.

font-display values explained

ValueWhat visitors see
swapFallback text at once, swaps to your font when loaded. Best for most sites.
fallbackVery short invisible period, then fallback; swaps only if your font arrives quickly
optionalUses your font only if it is already cached or arrives almost instantly
blockText invisible for up to a few seconds while the font loads; avoid for body text

Variable fonts

Many modern fonts come as a single variable font file that contains every weight from thin to black, and sometimes widths and slants too. Instead of five separate files for Light, Regular, Medium, Semibold and Bold, you upload one file and choose any weight in CSS.

For a variable font, write one @font-face rule with a weight range, for example font-weight: 100 900;, and then use any value like 450 or 650 in your styles. Variable fonts are a good choice when your design uses three or more weights; for just Regular and Bold, two static files are often smaller in total.

Fonts and languages

If your site has text in Hindi, Arabic, Chinese or another script, check that your chosen font actually contains those characters. Many Latin fonts do not, and the browser silently falls back to a system font for the missing letters, which can look mismatched. Pair your Latin brand font with a matching font for each script, for example a Devanagari font for Hindi, and list both in font-family.

Large fonts that cover many scripts can be heavy. Font services often split them into smaller pieces that load only when a character is needed; when self-hosting, prefer separate font files per script so English-only pages do not download Hindi glyphs.

Finding and choosing fonts

Not sure what font a site or image you like uses? See our guide on how to check what font is used. For free, web-licensed fonts, Google Fonts is a good starting point; filter by language support if you need Hindi or other scripts. Pick at most two families for a site, one for headings and one for body text, and test them on a phone before committing.

How we tested it

We tested Webfont Generator on 15 November 2026 with two free TTF fonts, DejaVu Sans regular (742 KB) and bold (692 KB), keeping WOFF2 and WOFF ticked.

The tool read both fonts (weight 400 and 700, over 6,000 glyphs each), made a kit of 1.17 MB in total and reported that the WOFF2 files were 66% smaller than the TTF originals. It also wrote one @font-face rule per weight with font-display: swap, ready to paste, and showed a preview line in each weight so we could check the bold really was bold. The sample font on the page gave a 52% saving.

How to use custom fonts on a website real test: two TTF fonts turned into a WOFF2 and WOFF kit with ready @font-face CSS
Our test: two TTF fonts turned into a webfont kit, with WOFF2 66% smaller and the CSS ready to copy.

Real examples

SituationWhat to do
Brand font in TTF from a designerCheck web licence → WOFF2 → upload → @font-face with swap
Google Font, but you want to self-hostDownload the family → convert to WOFF2 → host on your domain
WordPress blog with a custom heading fontUpload WOFF2 → add CSS in Additional CSS → apply to h1–h3
Icon font for a small landing pageEmbed WOFF2 in CSS (one file)
Not sure which font a site usesIdentify it first with Font Finder

Your fonts stay on your device

Webfont Generator converts fonts in your browser; the font files are never uploaded. That matters for licensed brand fonts that should not be shared. Only convert fonts whose licence allows web use.

Mistakes to avoid

  • Uploading TTF files directly and calling them from CSS. They work but are much heavier.
  • Wrong file paths. If the font does not show, open the browser’s developer tools (Network tab) and look for 404 errors on the font files.
  • One @font-face for all weights. Each weight and style needs its own block, with matching font-weight and font-style.
  • No fallback fonts in font-family.
  • Ignoring the licence. Desktop licences often exclude web use.
  • Loading eight weights when the design uses two.

Questions people ask

How do I use a custom font on my website?

Convert the font to WOFF2, upload it to your site, add an @font-face rule in your CSS pointing to the file, and use the font-family name in your styles with fallbacks.

How do I convert TTF to WOFF2?

Add the TTF to Webfont Generator, keep WOFF2 selected and press Make webfont kit. Download the zip with the WOFF2 file and the CSS.

Do I still need WOFF or TTF for the web?

For modern browsers, WOFF2 alone is enough. Add WOFF only if you must support very old browsers.

Why is my custom font not showing?

Usually the file path in the CSS is wrong, the file was not uploaded, or the font-family name in your styles does not match the @font-face name exactly.

Is it legal to use any font on my website?

Only if its licence allows web use. Free open-source fonts usually do; many paid fonts need a webfont licence.

Are my font files uploaded?

No. They are converted in your browser.

Is it free?

Yes. Without signing up you get a few free downloads a day, and a free email sign-up makes every tool unlimited.

The short version

To use custom fonts on a website, check the licence, convert the font to WOFF2, upload it to your site, add @font-face rules with font-display: swap, and use the font with fallbacks. Load only the weights you need and preload the main one for a fast, flicker-free page.

Anmol Sharma

I build and test FileFitly's tools myself. I started it after watching friends fight with online forms that rejected a PDF for being a few KB too big. Every tool runs in your browser, so your files never reach me, and I test each one on real phones and computers before it goes live.

Convert your font to WOFF2

Open Webfont Generator →

Sign up once. Use everything unlimited.

One free sign-up makes every tool unlimited on this device, and new guides and tools come to your inbox. No spam, leave with one click.

Only new guides, about once or twice a month. Unsubscribe any time. See our privacy policy.

Tools for this

More guides