tokenx
Fast token count estimates for LLM prompts in a 2 kB bundle.
How tokenx is used
tokenx joined the catalog on its public numbers (1,472,263 downloads a week on npm and 185 GitHub stars), not on our project count: it is a dependency in 9 public GitHub projects of our scan, 2 of them set up for AI coding agents. The most used alternative in our scan is GPT Tokenizer (14 projects). Projects that use it most often also use Vitest (100.0%), Zod (100.0%), Model Context Protocol SDK (JavaScript) (88.9%).
tokenx popularity over time
Gid Score 37: downloads 67, use in agent projects 16, GitHub stars 0, downloads trend 63 (each 0-100). How it is calculated.
Often used with tokenx
| Vitest | 100.0% of tokenx projects · 4.9× more than average |
|---|---|
| Zod | 100.0% of tokenx projects · 4.0× more than average |
| Model Context Protocol SDK (JavaScript) | 88.9% of tokenx projects · 9.4× more than average |
| Day.js | 88.9% of tokenx projects · 60.6× more than average |
| i18next | 88.9% of tokenx projects · 70.7× more than average |
| Lucide React | 88.9% of tokenx projects · 4.4× more than average |
| partial-json | 88.9% of tokenx projects · 613.1× more than average |
| PDF.js | 88.9% of tokenx projects · 64.9× more than average |
Install
| Package | npm install tokenx |
|---|---|
| Main stacks | Next.js (6), TypeScript / JavaScript (3) |
| Example projects | lobehub/lobehub, vual/lobe-chat-pro, 1600822305/AetherLink, liukailun007/PLC-Studio, MingyiSecLab/Mingyi-Atlas |
Alternatives to tokenx
Tools that do the same job, so a project picks one or the other. Add-ons and libraries used alongside tokenx 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 |
| tiktoken (JavaScript) npm JavaScript/WASM bindings for OpenAI's tokenizer for token counting. |
43 | 10 (0.2%) | 806K | 1,073 | MIT |
| js-tiktoken npm JavaScript implementation of OpenAI's tiktoken for counting and encoding tokens. |
51 | 5 (0.1%) | 5.7M | 1,073 | MIT |
More in Prompts, structured output and evals: Ultracite tiktoken (Python) tokenizers LangSmith Langfuse (Python) TokenLens @graphql-codegen/typescript-operations partial-json