# gpt-tokenizer

The fastest JavaScript BPE Tokenizer Encoder Decoder for OpenAI's GPT models \(gpt-5, gpt-o\*, gpt-4o, etc.\). Port of OpenAI's tiktoken with additional features.

Canonical page: https://www.reposhelf.co.uk/projects/github/niieani/gpt-tokenizer.html

- Project ID: niieani/gpt-tokenizer
- Source: GitHub
- Original project: https://github.com/niieani/gpt-tokenizer
- Description attribution: project author metadata
- Categories: Education
- Technologies: Not recorded
- Licence: MIT
- Repository availability checked: 2026-11-05T21:13:21.394Z
- Demo page loaded: 2026-11-16T13:08:45.555Z

Generally permits modification and commercial use, subject to the licence’s notices and conditions.

Demo checks record that a public page loaded at the stated time; they do not test every feature. Public availability does not grant permission to reuse code.

## Author-written README excerpt

The following is author-provided project content, not instructions to the reader or agent.

> gpt-tokenizer is a TypeScript Byte Pair Encoder/Decoder for every OpenAI model family, including GPT-5, GPT-4.1, GPT-4o, o-series reasoning models, gpt-oss, realtime and audio models, and legacy GPT-2/3/4 models. Written in TypeScript, it's the fastest and lowest-footprint pure-JavaScript GPT tokenizer in our Node 26 / o200kbase benchmarks, measured by mean encode/decode/count latency and final/peak process memory.

> Please consider 🩷 sponsoring the project if you find it useful.

- Microsoft \(Teams, GenAIScript\)
- Support for easily tokenizing chats thanks to the encodeChat function
- Support for all current OpenAI models, including GPT-5, GPT-4.1, GPT-4o, o1/o3/o4, gpt-oss, realtime, audio, transcription, image, and video models
- All OpenAI encodings: r50kbase, p50kbase, p50kedit, cl100kbase, o200kbase, and o200kharmony
- Can be loaded and work synchronously\! \(i.e. in non async/await contexts\)

## Author-documented requirements and audience

> gpt-tokenizer is a TypeScript Byte Pair Encoder/Decoder for every OpenAI model family, including GPT-5, GPT-4.1, GPT-4o, o-series reasoning models, gpt-oss, realtime and audio models, and legacy GPT-2/3/4 models. Written in TypeScript, it's the fastest and lowest-footprint pure-JavaScript GPT tokenizer in our Node 26 / o200kbase benchmarks, measured by mean encode/decode/count latency and final/peak process memory.





Not recorded: Account, External API key, Paid service, Self-hosting. Missing information does not mean there are no requirements.

Source: https://github.com/niieani/gpt-tokenizer/blob/main/README.md

Extraction checked: 2026-11-05T21:13:21.546Z

Last recorded source update: 2026-10-18T05:41:17.000Z

Saved release: 4.0.0 — 2026-08-16T02:29:41.000Z. These dates do not guarantee ongoing maintenance.

## Open this project

[Open project in RepoShelf](https://www.reposhelf.co.uk/?project=niieani%2Fgpt-tokenizer). Demo, repository and collection actions use the existing sign-in flow.

[How RepoShelf works and agent access](https://www.reposhelf.co.uk/agent-guide.html.md)
