Skip to content
r.

gpt-tokenizer

niieani/gpt-tokenizer · Public GitHub repository

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.

Open project in RepoShelf

Open the project to try its demo, view the repository, or save it to your collection. Repository and demo actions use RepoShelf’s sign-in flow.

gpt-tokenizer live demo screenshot
Captured from the live demo · 2026-11-02

About this project

Author-written excerpt from the project README.

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.

Requirements and intended 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.

Statements extracted from the author’s documentation · Checked 2026-11-05. Source: https://github.com/niieani/gpt-tokenizer/blob/main/README.md

Recorded maintenance information

Last recorded source update: 2026-10-18. Saved release: 4.0.0 · 2026-08-16. These dates do not guarantee ongoing maintenance.

Technologies
TypeScript
Licence
MIT. Generally permits modification and commercial use, subject to the licence’s notices and conditions.
Demo check
A public page loaded on 2026-11-16. This does not test every feature.

Browse related categories