Font Face Generator

Drag & drop local files to generate robust @font-face code, or browse our visual library of Google Fonts and modern CSS font stacks.

Drop .ttf, .otf, .woff
?
Where will you host this file relative to your CSS?
Typography Settings
0px
1.5

Live Preview

The quick brown fox jumps over the lazy dog.

1234567890
!@#$%^&*()_+
CSS Output
/* Generated CSS */

Popular Font Stacks

Instantly copy common font-family stacks and @font-face snippets.

What is the Font Face Generator?

The Font Face Generator is a free online tool that helps you generate @font-face CSS code for custom fonts. Instead of relying on system fonts or third-party services, this tool allows you to use your own font files directly on your website.

Why Use a Font Face Generator?

Writing @font-face declarations manually is tedious and prone to syntax errors. Here is why web developers and designers use this tool:

How to Use the Font Face Generator

Follow these simple steps to add custom typography to your project:

  1. Upload Your Font: Drag and drop your .ttf, .otf, or .woff file into the upload box. The tool will instantly create a live preview.
  2. Configure Settings:
    • Font Family: Give your font a name (e.g., "MyBrandFont").
    • Weight & Style: accurate mappings (e.g., 700 for Bold, Italic) ensure the browser knows when to use this specific file.
    • Asset Path: Enter the folder path where you will upload the file on your server (e.g., /assets/fonts/).
  3. Copy the CSS: Click the "Copy" button to grab the generated code.
  4. Implement: Paste the code at the top of your CSS file. Then, upload your font files to the folder path you specified in step 2.

What is the CSS @font-face Rule?

In the early days of the web, designers were limited to "Web Safe Fonts" like Arial, Times New Roman, and Verdana—fonts that were guaranteed to be installed on the user's computer.

The @font-face CSS rule changed everything. It allows you to define a custom font name and point to a font file hosted on your web server. When a user visits your site, their browser downloads the font file temporarily to display your text exactly as you intended, regardless of whether they have that font installed on their device.

Frequently Asked Questions

Which font formats should I use for the web?

Hosting fonts locally (instead of using the Google CDN link) reduces DNS lookups, allows for better caching control, and eliminates privacy concerns regarding tracking user IP addresses, which is crucial for GDPR compliance in Europe.

Where do I paste the generated code?

Paste the generated @font-face block at the very top of your main CSS stylesheet (e.g., style.css). Afterward, you can use the font family in your classes like this: body { font-family: 'MyFontName', sans-serif; }.

What is the Asset Path?

The Asset Path is the directory on your web server where the actual font files live. For example, if you are using WordPress, your path might look like /wp-content/themes/your-theme/fonts/. If you are using standard HTML/CSS, it might simply be /fonts/.

Do I need multiple font formats?

For most modern websites, WOFF2 and WOFF are enough. Older formats are rarely needed today.

Is it legal to use any font?

Only if the font license allows web embedding. Always check licensing before using a font.

Why isn’t my font showing up?

This is usually caused by incorrect file paths, missing formats, or caching issues. Double-check the URLs and reload the page.