Home › Developer Tools › CSS @font-face Generator

CSS @font-face Generator

Add your font files (or their URLs) and get clean @font-face rules with the right formats, weights and styles, read straight from the fonts themselves. Preview every face before you paste the CSS; files never leave your device.

Last updated:

Choose font files or drop them here WOFF2, WOFF, TTF, OTF or EOT · several weights at once

Font faces 0

@font-face CSS

      
Preload tags for your <head>

        
Advertisement
Advertisement

How to use the CSS @font-face Generator

  1. Add fonts: choose or drop your .woff2, .woff, .ttf or .otf files, or paste a font URL and press Add URL.
  2. Check each face: the family, weight and style are filled in from the font; adjust them if needed.
  3. Set the path where the files will live on your site (for example /fonts/), and choose font-display and a unicode-range.
  4. Preview the faces with your own sample text.
  5. Copy the CSS (and the optional preload tags) or download it as a .css file.

Font formats and their format() names

Fileformat()MIME typeNotes
.woff2format('woff2')font/woff2Brotli compressed; smallest; all current browsers. List it first.
.woffformat('woff')font/woffzlib compressed; fallback for very old browsers (IE 9-11).
.ttfformat('truetype')font/ttfUncompressed desktop font; works but is much larger.
.otfformat('opentype')font/otfOpenType with CFF outlines; uncompressed.
.eotformat('embedded-opentype')application/vnd.ms-fontobjectInternet Explorer 6-8 only; obsolete.

The browser walks the src list from left to right and downloads the first format it supports, so the smallest format goes first. Need WOFF2 files? Convert TTF fonts with the TTF to WOFF2 converter.

One family, many weights

Give every file of a family the same font-family name and describe it with font-weight and font-style. Then font-weight: 700 or <strong> picks the bold file automatically and the browser never has to fake bold or italic. A variable font covers a whole range in one file: declare it with a range such as font-weight: 100 900;.

Common weight names: 100 Thin, 200 Extra Light, 300 Light, 400 Regular, 500 Medium, 600 Semi Bold, 700 Bold, 800 Extra Bold, 900 Black.

Fast loading checklist

  • Serve WOFF2 and use font-display: swap (or optional for zero layout shift).
  • Preload only the one or two fonts used above the fold; crossorigin is required on font preloads even for same-origin files.
  • Split large fonts with unicode-range so visitors only download the scripts they need.
  • Cache font files for a long time (for example Cache-Control: max-age=31536000, immutable).

Frequently asked questions

What is @font-face?

@font-face is the CSS at-rule that loads a custom font file and gives it a family name. Once declared, you use that name in font-family like any other font. Each combination of weight and style needs its own @font-face rule with the same font-family name.

Which font formats do I need today?

WOFF2 alone is supported by every current browser and is the smallest. Adding WOFF covers very old browsers such as Internet Explorer 9-11. TTF/OTF work but are larger, and EOT and SVG fonts are only needed for long-obsolete browsers.

What does font-display: swap do?

It shows the text immediately in a fallback font and swaps to the web font when it has loaded, so text is never invisible. fallback and optional limit how late the swap can happen, which reduces layout shift; block hides text briefly while the font loads.

What is unicode-range for?

unicode-range tells the browser which characters a font file covers. If a page uses no characters in that range, the file is not downloaded at all. It lets you split a font into subsets such as Latin and Cyrillic, like Google Fonts does.

Why is my font not loading?

Check that the url() paths are correct relative to the CSS file, that the server sends the font with a correct MIME type, and that fonts served from another domain include an Access-Control-Allow-Origin header. The family name in font-family must match the @font-face name exactly.

Should I embed fonts as Base64?

Usually not. Base64 makes the font about 33% larger, blocks CSS parsing until it is downloaded and cannot be cached separately. It can be handy for a single small icon font or an HTML email, but normal font files with preload are faster.

Am I allowed to self-host a font?

That depends on the font license. Open-source fonts such as those under the SIL Open Font License can be self-hosted freely; commercial fonts often need a webfont license. Check the license before publishing font files on your site.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

Font ViewerPreview TTF, OTF, WOFF and WOFF2 fonts with sample text, waterfall, glyphs and metadata.TTF to WOFF2 ConverterConvert TTF and OTF fonts to WOFF2 or WOFF and get a ready @font-face CSS snippet.CSS Media Query GeneratorBuild @media rules for widths, orientation, dark mode and hover, or get framework breakpoints.HTML Boilerplate GeneratorTick the options you need and get a clean HTML5 starter template with meta, OG tags and CSS reset.Text Pixel Width CalculatorMeasure how many pixels wide text renders in any font and size, and check it against a limit.Text to SVG PathTurn text in any Google or uploaded font into SVG path outlines for Cricut, laser and logos.Typography Scale GeneratorBuild a modular type scale from a base size and ratio, then copy CSS variables or a Tailwind config.Open Graph PreviewPaste OG tags and preview how links look on Facebook, X and LinkedIn.YouTube Embed Code GeneratorCreate responsive YouTube embed code with start time, autoplay, loop and privacy mode.CSS Box Shadow GeneratorDesign layered CSS box shadows with a live preview, presets and one-click Copy CSS.CSS Border Radius GeneratorRound each corner, draw elliptical 8-value radii or random blob shapes and copy the CSS.CSS Button GeneratorDesign CSS buttons with gradients, borders, shadows and hover and active states, then copy the code.CSS Flexbox GeneratorBuild flexbox layouts visually: set container and item properties, then copy the CSS and HTML.Twitter Card GeneratorCreate X / Twitter Card meta tags with Open Graph fallbacks, character counters and a live preview.CSS Grid GeneratorDraw CSS grid layouts: set tracks and gaps, drag to name areas, then copy the CSS and HTML.PX to REM ConverterConvert px to rem or em and back, with a 1-100px table and a whole-CSS converter.Glassmorphism CSS GeneratorDesign frosted-glass UI cards with blur, transparency and border sliders, then copy the CSS.CSS Text Shadow GeneratorLayer CSS text shadows with a live preview and neon, 3D, outline and retro presets.HTML Editor (Live Preview)Write HTML, CSS and JavaScript and see a live, sandboxed preview as you type.HTML to JSX ConverterConvert HTML to valid React JSX: className, htmlFor, style objects, self-closing tags and events.CSS Clip-Path GeneratorDraw CSS clip-path shapes by dragging points: polygons, circle, ellipse and inset. Copy the CSS.CSS Animation GeneratorCreate CSS keyframe animations from 23 presets with live preview, timing controls and Copy CSS.CSS Triangle GeneratorMake CSS triangles in 8 directions with the border trick or clip-path. Set size and color, copy CSS.CSS Loader GeneratorPick from 14 pure CSS spinners and loaders, set color, size and speed, then copy the HTML and CSS.Cubic Bezier GeneratorDrag the control points to design a CSS easing curve, compare it with linear and copy cubic-bezier().CSS Filter GeneratorAdjust blur, brightness, contrast, hue, sepia and drop-shadow on an image and copy the CSS filter.CSS Specificity CalculatorCalculate CSS selector specificity (a, b, c), including :is(), :not(), :has() and :where(), and compare.Google Maps Embed GeneratorTurn an address or coordinates into responsive Google Maps iframe embed code, no API key.Neumorphism CSS GeneratorDesign soft UI neumorphic shapes with live preview and copy the box-shadow CSS.SVG Wave GeneratorMake layered SVG waves for section dividers and export SVG, PNG or a CSS background.SVG Blob GeneratorGenerate random organic SVG blob shapes with gradients and export SVG, PNG or CSS clip-path.CSS Clamp GeneratorTurn min/max sizes and viewport widths into a fluid CSS clamp() value in rem and vw.CSS Scrollbar GeneratorStyle scrollbars: width, colors, radius and hover, with ::-webkit-scrollbar and scrollbar-color CSS.CSS Sprite GeneratorPack many icons into one sprite sheet PNG and get CSS classes with background-position.CSS Text Gradient GeneratorMake gradient text with background-clip:text: color stops, angle, font preview and fallback CSS.CSS Toggle Switch GeneratorDesign pure-CSS toggle switches: size, colors, shape and animation. Copy accessible HTML + CSS.CSS Tooltip GeneratorBuild pure CSS tooltips: position, arrow, colors, padding and animation. Copy HTML and CSS.HTML Form BuilderDrag and drop form fields with labels and validation, then copy accessible HTML and CSS code.HTML Accessibility CheckerPaste HTML to find WCAG accessibility problems with impact level, the failing element and a fix.HTML Image Map GeneratorDraw clickable rectangle, circle and polygon hotspots on an image and get image map HTML.SVG ViewerOpen or paste SVG code to preview it live with zoom, backgrounds, size info and PNG export.Pathfinding VisualizerAnimate BFS, DFS, Dijkstra, A* and greedy search on a grid with walls, weights and mazes.Iframe GeneratorCreate iframe embed code: size or responsive ratio, border, allow, sandbox, lazy load, live preview.PX to VW ConverterConvert pixels to vw and vh for any viewport size, and vw/vh back to px, with breakpoint tables.SVG Path EditorEdit an SVG path d attribute visually: drag points, edit commands, convert, scale and minify.SVG to CSS Data URITurn SVG code into a small URL-encoded data URI for CSS backgrounds, with Base64 size comparison.SVG to JSXTurn SVG code into a clean React component: camelCase attributes, style objects, TypeScript.Tailwind CSS Cheat SheetSearchable Tailwind class to CSS reference with live previews, class decoder and color palette.Web App Manifest GeneratorCreate a PWA manifest.json and every app icon size from one image, downloaded as a ZIP.CSS Background Pattern GeneratorMake pure-CSS stripes, dots, checkerboard, zigzag and grid backgrounds and copy the code.CSS Color Filter GeneratorTurn a HEX color into a CSS filter that recolors black icons and SVGs, with an accuracy score.CSS Gradient Animation GeneratorCreate animated gradient backgrounds: pick colors, angle and speed, preview live and copy the CSS.CSS Hover Effects GeneratorPick button, link and image hover effects, tweak colors and timing, and copy the HTML and CSS.CSS InlinerMove CSS from style blocks into inline style attributes so HTML emails render in every client.CSS Shape Divider GeneratorCreate wave, tilt, curve and triangle section dividers and copy the SVG, HTML and CSS.CSS Transform GeneratorRotate, scale, skew and translate an element with sliders and copy the CSS transform code.Font Pairing ToolPreview Google Font heading and body pairs on real layouts and copy the embed code and CSS.
See all 52 Web, HTML & CSS Tools →