WOFF, WOFF2, TTF and OTF: which font file format to use
Upload WOFF2. For nearly every site that's the whole answer, and the rest of this page explains why.1
The four formats
| Format | What it is | Use it on a site? |
|---|---|---|
| TTF (TrueType) | A font made for installing on a computer | Usually only as the file you start from |
| OTF (OpenType) | A related desktop format with more features | Usually only as the file you start from |
| WOFF | A TrueType or OpenType font, compressed for the web | Only if you need very old browsers |
| WOFF2 | The newer web version, compressed further | Yes, this is the one1 |
WOFF files are OpenType or TrueType fonts with compression applied and extra XML information added.2 So nothing about the letter shapes changes. Only the packaging does.
Why WOFF2 wins
- It's smaller. WOFF2 compresses 30% better than WOFF, so there's less to download.3
- Browsers handle it. All modern browsers support WOFF2.1
- It's the current advice. web.dev notes that experts now recommend only using WOFF2.3
- It keeps things simple. MDN suggests providing as few web font files as possible, which means fewer files for your site to serve.1
Do you still need the old ones?
Probably not. Ask yourself two things:
- Do your visitors use very old browsers? If you do need to support older browsers in a real-world project, you may also need to provide WOFF.1 MDN points to the browser compatibility table for
@font-faceto check how far back support goes.1 - Is the font essential to the page? If it isn't, a visitor on an old browser can simply see your fallback font. [page:system-fonts-and-font-stacks] covers how to set that up.3
If you do list two formats, put your preferred one first in src.1
Getting a WOFF2 file
Fonts you download are often TTF or OTF, and either works as a starting point.1 Some downloads already include WOFF2 files, so look inside the ZIP first.
- Check the licence. Converting a font can count as changing it. Under the SIL Open Font Licence, a change in font format normally is considered modification.4 A WOFF or WOFF2 version can be made so that it is not considered modification, but only if the original font data stays unchanged except for the compression.4 Any WOFF metadata must be left out or carry over the original font's metadata unaltered.4 Some conversion tools and online services don't meet that, so check the tool you use as well as the licence.4 Read [page:font-licences-in-plain-words] before you convert.
- Use a converter that outputs WOFF2 only. MDN's walkthrough uses an online generator and unticks the WOFF box.1
- Upload the result to your site, and point
@font-faceat it.
Server settings
Your server should send the right file type label (MIME type) for font files. The standard labels, in use since February 2017, are font/woff for WOFF and font/woff2 for WOFF2.2 An older label for WOFF, application/font-woff, is now deprecated.2
Some servers need the type added by hand before they serve the files correctly.2 If your font won't load and the file path is right, ask your host about this.
Quick decision list
Cited material
- Web fonts - Learn web development, MDN Web Docs (Mozilla)
- Web Open Font Format, Wikipedia
- Best practices for fonts, web.dev (Google)
- OFL FAQ, SIL Global
