# @pierre/highlights

> A fast code highlighter written in WebAssembly Text(Wat), from Pierre

Latest version **0.3.0** (published 2026-10-26) · apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @pierre/highlights
pnpm add @pierre/highlights
yarn add @pierre/highlights
bun add @pierre/highlights
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2026-10-26 |
| First published | 2026-09-09 |
| Weekly downloads | 0 |
| License | apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 1.7 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | fat, imownbey, mdo, nicolas.pierreco, ije, slexaxton, amadeusdemarzi |

## Links

- npm: https://www.npmjs.com/package/@pierre/highlights
- npm.io page: https://npm.io/package/@pierre/highlights

## Recent versions

- 0.3.0 (latest) — 2026-10-26
- 0.2.0 — 2026-10-21
- 0.1.3 — 2026-10-08
- 0.1.2 — 2026-10-05
- 0.1.1 — 2026-10-05
- 0.1.0 — 2026-10-02
- 0.0.5 — 2026-09-29
- 0.0.4 — 2026-09-18
- 0.0.3 — 2026-09-15
- 0.0.2 — 2026-09-14
- 0.0.1 — 2026-09-09

## README

# Highlights, from Pierre

`@pierre/highlights` is a syntax highlighter written in WebAssembly Text (WAT).
It supports 120 built-in languages and Zed-compatible themes. It produces HTML
or themed tokens from complete input, input chunks, or document edits.

Read the [Documentation](https://diffs.com/docs#highlights).

## Installation

```bash
pnpm add @pierre/highlights
```

The package runs in Node.js, browsers, and Cloudflare Workers. It initializes
WebAssembly at import. `codeToHtml()` and `codeToTokens()` run synchronously
after import.

## Quick start

```js
import { codeToHtml } from '@pierre/highlights';
import { pierreDark } from '@pierre/highlights/themes';

const htmlBytes = codeToHtml("console.log('Hello world!')", {
  lang: 'js',
  theme: pierreDark,
});
const html = new TextDecoder().decode(htmlBytes);
```

`codeToHtml()` returns UTF-8 HTML bytes that can share WebAssembly memory.

Decode the bytes before the next call to the highlighter. Use `.slice()` to keep
a copy for later use.

Read the [API reference](https://diffs.com/docs#highlights) for tokens, input
streams, document edits, and themes.

## Development

```bash
moonx highlights:build
moonx highlights:dev
moonx highlights:test
moonx highlights:bench
moonx highlights:bench-live
moonx highlights:bench-memory
```

[Benchmarks](./benchmark/README.md) · [Architecture](./ARCHITECTURE.md) ·
[Bundled themes](./themes/README.md)

## License

[Apache-2.0](./LICENSE.md)

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