# ttf2woff2

> Convert TTF files to WOFF2 ones.

Latest version **8.0.1** (published 2026-02-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install ttf2woff2
pnpm add ttf2woff2
yarn add ttf2woff2
bun add ttf2woff2
```

Provides the command `ttf2woff2`.

## Health

**Score 60/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 8.0.1 |
| Published | 2026-02-28 |
| First published | 2015-06-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=20.11.1 |
| Dependencies | 6 |
| Unpacked size | 4.2 MB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 342 |
| Author | Nicolas Froidure |
| Maintainers | sabberworm, nfroidure, pioug |
| Keywords | ttf, woff2, fonts |

## Links

- npm: https://www.npmjs.com/package/ttf2woff2
- Repository: https://github.com/nfroidure/ttf2woff2
- Issues: https://github.com/nfroidure/ttf2woff2/issues
- npm.io page: https://npm.io/package/ttf2woff2

## Dependencies (6)

- [nan](https://npm.io/package/nan.md) ^2.22.2
- [debug](https://npm.io/package/debug.md) ^4.4.1
- [yerror](https://npm.io/package/yerror.md) ^8.0.0
- [bindings](https://npm.io/package/bindings.md) ^1.5.0
- [node-gyp](https://npm.io/package/node-gyp.md) ^11.2.0
- [bufferstreams](https://npm.io/package/bufferstreams.md) ^4.0.0

## Recent versions

- 8.0.1 (latest) — 2026-02-28
- 8.0.0 — 2025-06-02
- 7.0.0 — 2025-05-22
- 6.0.1 — 2024-07-20
- 6.0.0 — 2024-07-20
- 5.0.0 — 2022-12-05
- 4.0.5 — 2022-04-23
- 4.0.4 — 2021-07-23
- 4.0.3 — 2021-05-28
- 4.0.2 — 2021-03-17
- 4.0.1 — 2020-12-22
- 4.0.0 — 2020-12-22
- 3.0.0 — 2019-05-27
- 2.0.3 — 2015-11-20
- 2.0.2 — 2015-11-08
- … 11 more at https://npm.io/package/ttf2woff2/versions

## README

[//]: # ( )
[//]: # (This file is automatically generated by a `metapak`)
[//]: # (module. Do not change it  except between the)
[//]: # (`content:start/end` flags, your changes would)
[//]: # (be overridden.)
[//]: # ( )
# ttf2woff2
> Convert TTF files to WOFF2 ones.

[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/nfroidure/ttf2woff2/blob/main/LICENSE)


[//]: # (::contents:start)

This is a NodeJS wrapper for the Google [WOFF2](https://github.com/google/woff2)
project. If the C++ wrapper compilation fail, it
[fallbacks to an Emscripten build](http://insertafter.com/en/blog/native-node-module.html).

## Usage

### CLI

Install `ttf2woff2` globally, then:

```sh
cat font.ttf | ttf2woff2 > font.woff2
```

On Windows without `cat`, use (in PowerShell):

```pwsh
Start-Process -NoNewWindow -Wait ttf2woff2.cmd -RedirectStandardInput font.ttf -RedirectStandardOutput font.woff2
# OR
start-process -nnw -wait ttf2woff2.cmd -rsi font.ttf -rso font.woff2
```

### API

```js
import { readFile, writeFile } from 'node:fs/promises';
import ttf2woff2 from 'ttf2woff2';

const input = await readFile('font.ttf');

await writeFile('font.woff2', ttf2woff2(input));
```

## Development

To build the binary, clone the repository and run the following:

```
## Setup (works for Ubuntu/Linux, may be different on other OS)
apt-get install make g++

## Actual build
npm i
npm run configure
npm run make
```

To build the Emscripten fallback, install [Emscripten](https://emscripten.org/) and run:

```
npm run emcc
```

Finally the build can be tested:
```sh
npm run build
npm t
```

## Contributing

Feel free to push your code if you agree with publishing under the MIT license.

[//]: # (::contents:end)

# Authors
- [Nicolas Froidure](https://insertafter.com/en/index.html)
- [Anders Kaseorg](mailto:andersk@mit.edu)

# License
[MIT](https://github.com/nfroidure/ttf2woff2/blob/main/LICENSE)

---
_Source: https://npm.io/package/ttf2woff2 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
