# fnv1a52

> A fast 52-bit FNV-1a hash implementation for JavaScript.

Latest version **1.0.0** (published 2026-07-26) · MIT license · 0 weekly downloads

## Install

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

## Health

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

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2026-07-26 |
| First published | 2026-07-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18.0.0 |
| Dependencies | 0 |
| Unpacked size | 9.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1 |
| Author | SukkaW <https://skk.moe> |
| Maintainers | sukkaw |
| Keywords | fnv, fnv1a, fnv-1a, fnv1a52, base36, hash, hashing, checksum |

## Links

- npm: https://www.npmjs.com/package/fnv1a52
- Repository: https://github.com/SukkaW/fnv1a52
- npm.io page: https://npm.io/package/fnv1a52

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2026-07-26
- 1.0.0-beta.1 (next) — 2026-07-26
- 0.0.0 — 2026-07-26

## README

# fnv1a52

> A fast 52-bit [FNV-1a](https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function) hash implementation for JavaScript

52 bits provides a larger hash space than the classic 32-bit FNV-1a while still fitting entirely inside JavaScript's 53-bit safe integer range (double precision) — so the result is a plain `number`, no `BigInt` required. Zero dependencies.

The implementation is based on prior work by [@tjwebb](https://github.com/tjwebb) (Travis Webb) and [@desudesutalk](https://github.com/desudesutalk) under the MIT license, with extra simplifacations and optimizations (like inline lookup table and faster hex conversion).

> If you need full 64 bits hash space, check out [@danielroe](https://github.com/danielroe)'s https://github.com/danielroe/fnv1a-64

## Install

```sh
pnpm add fnv1a52
yarn add fnv1a52
npm install fnv1a52
```

## Usage

```js
import { fnv1a52, fnv1a52base36, fnv1a52hex } from 'fnv1a52';

console.log(fnv1a52('hello world'));
//=> 2926792616498590

console.log(fnv1a52hex('hello world'));
//=> 'a65e7023cd59e'

console.log(fnv1a52base36('hello world'));
//=> '0stglysbf6m'
```

> You should NEVER `fnv1a52().toString(16)`! `fnv1a52hex` can get you a fixed length zero-padded hex string **up to 6x faster** via a byte-to-hex lookup table.

> The same applies to `fnv1a52().toString(36)` — always use `fnv1a52base36` instead, which can get you a fixed length zero-padded hex string **up to 3x faster**.

## API

### `fnv1a52(str)`

Returns the 52-bit FNV-1a hash of `str` as a `number`.

- **str**: `string`

### `fnv1a52hex(str)`

Returns the 52-bit FNV-1a hash of `str` as a lowercase hexadecimal `string` (fixed length, zero-padded).

- **str**: `string`

Prefer this over `fnv1a52(str).toString(16)` — it uses a byte-to-hex lookup table and is up to 6x faster.

Note the fixed length means this is **not** always equal to `fnv1a52(str).toString(16)`: a hash below `16 ** 12` keeps its leading zero here, while `toString(16)` drops it.

### `fnv1a52base36(str)`

Returns the 52-bit FNV-1a hash of `str` as a lowercase base36 `string` (fixed length, zero-padded).

- **str**: `string`

Prefer this over `fnv1a52(str).toString(36)` as it is up to 3x faster.

## Benchmark

```
$ pnpm run bench

clk: ~3.15 GHz
cpu: Apple M2 Max
runtime: node 24.18.0 (arm64-darwin)

• fnv1a52 - hex
------------------------------------------------ -------------------------------
fnv1a52 + toString(16)            656.58 ns/iter
fnv1a52hex                        120.82 ns/iter

• fnv1a52 - base36
------------------------------------------------ -------------------------------
fnv1a52 + toString(36) + padStart 506.29 ns/iter
fnv1a52base36                     137.43 ns/iter
```

## License

[MIT](LICENSE)

----

**fnv1a52** © [Sukka](https://github.com/SukkaW), Released under the [MIT](./LICENSE) License.
Authored and maintained by Sukka with help from contributors ([list](https://github.com/SukkaW/fnv1a52/graphs/contributors)).

> [Personal Website](https://skk.moe) · [Blog](https://blog.skk.moe) · GitHub [@SukkaW](https://github.com/SukkaW) · Telegram Channel [@SukkaChannel](https://t.me/SukkaChannel) · Mastodon [@sukka@acg.mn](https://acg.mn/@sukka) · Twitter [@isukkaw](https://twitter.com/isukkaw) · BlueSky [@skk.moe](https://bsky.app/profile/skk.moe)

<p align="center">
  <a href="https://github.com/sponsors/SukkaW/">
    <img src="https://sponsor.cdn.skk.moe/sponsors.svg"/>
  </a>
</p>

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