tiktoken (JavaScript)
JavaScript/WASM bindings for OpenAI's tokenizer for token counting.
How tiktoken (JavaScript) is used
tiktoken (JavaScript) is a dependency in 10 of the 6,208 public GitHub projects set up for AI coding agents that we scanned, too few to describe it from them alone. Our scan also samples projects by dependency (Solana 2,661, Ethereum and EVM 1,496, 3D and games 2,818, agent frameworks and SDKs 10,983); counting those, it appears in 46 projects, and what it is used with below comes from all of them. The most used alternative in our scan is GPT Tokenizer (14 projects). Projects that use it most often also use tsx (67.4%), react-markdown (54.3%), uuid (54.3%).
tiktoken (JavaScript) popularity over time
Gid Score 43: downloads 62, use in agent projects 40, GitHub stars 13, downloads trend 56 (each 0-100). How it is calculated.
Often used with tiktoken (JavaScript)
| tsx | 67.4% of tiktoken (JavaScript) projects · 4.5× more than average |
|---|---|
| react-markdown | 54.3% of tiktoken (JavaScript) projects · 13.9× more than average |
| uuid | 54.3% of tiktoken (JavaScript) projects · 11.6× more than average |
| Model Context Protocol SDK (JavaScript) | 50.0% of tiktoken (JavaScript) projects · 5.3× more than average |
| Next.js | 58.7% of tiktoken (JavaScript) projects · 3.3× more than average |
| Ajv | 47.8% of tiktoken (JavaScript) projects · 19.7× more than average |
| Zod | 67.4% of tiktoken (JavaScript) projects · 2.7× more than average |
| Commander | 41.3% of tiktoken (JavaScript) projects · 14.9× more than average |
From all 46 projects in our scan that use tiktoken (JavaScript), including the dependency samples.
By coding agent
| Claude Code | 0.2% of projects set up for it |
|---|---|
| GitHub Copilot | 0.3% of projects set up for it |
| Gemini CLI | 1.3% of projects set up for it |
Share of public repos configured for each agent that list tiktoken (JavaScript) as a dependency.
Install
| Package | npm install tiktoken |
|---|---|
| Main stacks | Next.js (27), TypeScript / JavaScript (18), Python (1) |
| Example projects | diegosouzapw/OmniRoute, run-llama/chat-llamaindex, XiaoPuOuO/openchatx-mcp, massdo/repomix-runner, Superexpert/superexpert-ai |
Alternatives to tiktoken (JavaScript)
Tools that do the same job, so a project picks one or the other. Add-ons and libraries used alongside tiktoken (JavaScript) are not listed here; they are in "Often used with".
| Tool | Gid Score | Used in agent projects | Downloads / wk | GitHub stars | License |
|---|---|---|---|---|---|
| GPT Tokenizer npm JavaScript BPE tokenizer with pricing and token counts for OpenAI models. |
44 | 14 (0.3%) | 1.2M | 855 | MIT |
| js-tiktoken npm JavaScript implementation of OpenAI's tiktoken for counting and encoding tokens. |
51 | 5 (0.1%) | 5.7M | 1,073 | MIT |
| tokenx npm · new in the catalog Fast token count estimates for LLM prompts in a 2 kB bundle. |
37 | 2 (0.0%) | 1.5M | 185 | MIT |
More in Prompts, structured output and evals: Ultracite tiktoken (Python) tokenizers LangSmith Langfuse (Python) TokenLens @graphql-codegen/typescript-operations partial-json