---
title: "Brotli"
description: "RFC 7932 read in full. Context modeling and the built-in dictionary of 120 KiB of web words. Read only"
canonical_url: "https://compressions.agntn.dev/formats/brotli"
---
# Brotli

> RFC 7932 read in full. Context modeling and the built-in dictionary of 120 KiB of web words. Read only

<format-facts name="brotli">



</format-facts>

What your browser asked for when it said `Accept-Encoding: br`. LZ77 with Huffman codes that switch by context, and a built-in dictionary of words that show up on web pages, each one in 121 transformed forms. A distance past the window points into that dictionary instead of into the output.

```ts
decompress("brotli", Buffer.from("1f3200f88dd44e777726aa32b40609617b53b358530d6440358300", "hex"));
// { bytes: "hello world! hello world! hello world! hello world!",
//   details: { window: 16777200, metaBlocks: 1 } }
```

27 bytes from `brotli` 1.2.0 for 51 bytes of text.

## Read only

Same reason as zstd: the writer is a project of its own, and `brotli` is a package install away. `compress("brotli", …)` throws and says so.

## No magic, no checksum

A brotli stream starts with its window size in a few bits, and that's it. No magic number, no checksum. So [identify](https://compressions.agntn.dev/guide/identify) only counts brotli when it decodes every byte and gives something back, and even then scores it low. Random bytes decode as brotli now and then. A damaged stream can decode into the wrong bytes without an error, because there's nothing to check them against.

The dictionary ships inside the package, deflated and in base64, and gets inflated by this package's own deflate on first use.


## Sitemap

See the full [sitemap](https://compressions.agntn.dev/sitemap.md) for all pages.
