Tokenizer Lab is an interactive React + Vite application for exploring how modern multilingual and frontier model tokenizers behave on real text. It lets you inspect token segmentation, compare models side-by-side, and batch-export metrics for downstream analysis without leaving the browser.
␣, tabs to ⇥, and newlines to ⏎.� replacement character, and hex representations are used when decoding is impossible.| Category | Model ID | Display name | Implementation |
|---|---|---|---|
| General purpose | Xenova/bert-base-multilingual-uncased | mBERT (Multilingual BERT) | Transformers.js |
| General purpose | Xenova/t5-small | T5 | Transformers.js |
| General purpose | Xenova/xlm-roberta-base | XLM-RoBERTa | Transformers.js |
| General purpose | Xenova/bert-base-uncased | BERT (English) | Transformers.js |
| General purpose | Xenova/distilgpt2 | DistilGPT‑2 | Transformers.js |
| Indic specialists | ai4bharat/IndicBERTv2-MLM-only | IndicBERT v2 MLM | Transformers.js |
| Indic specialists | InvincibleSloth/muril-tokenizer | MuRIL | Transformers.js |
| Frontier / production | openai/tiktoken/cl100k_base | OpenAI GPT‑4 family (cl100k_base) | Tiktoken WASM |
| Frontier / production | openai/tiktoken/o200k_base | OpenAI GPT‑4o mini (o200k_base) | Tiktoken WASM |
| Frontier / production | anthropic/claude-3-opus-20240229 | Anthropic Claude 3 Opus | Tiktoken WASM |
| Frontier / production | meta-llama/Meta-Llama-3.1-8B-Instruct | Meta Llama 3.1 8B Instruct | Transformers.js |
| Frontier / production | mistralai/Mistral-7B-Instruct-v0.3 | Mistral 7B Instruct v0.3 | Transformers.js |
Note: Meta and Mistral repositories are gated. You must visit their model page on Hugging Face with the same account as your access token and accept the terms before they will load successfully.
Every tokenization run surfaces:
[start, end]) whenever a tokenizer supports them.tokenCountcharCount (grapheme clusters)byteCounttokensPer100CharsbytesPerTokenavgTokenLengthunkPercentageIn Batch mode, the application:
Switching modes preserves your text input so you can iterate without retyping.
Auto mode runs inside a dedicated web worker that samples your pasted lines, applies the selected mutation axes, and streams results back as CSV chunks. You can cancel the worker at any point, keep the streamed rows for inspection, and download the accumulated CSV once a chunk has arrived. The download controls keep the exact config JSON so the provenance embedded in every row stays reproducible.
Numeric sweep axes (ascii_ratio, emoji_count, perturbations) emit numeric x_value entries to make downstream plotting easier.
AutoSweep CSV rows are emitted in the following order:
@radix-ui/themes, clsx, class-variance-authority) for styling.hf object) to load Hugging Face tokenizers in the browser.npm install
npm run dev
Open the printed local URL (typically http://localhost:5173) to load the app.
npm run build
Preview the output with npm run preview.
https://huggingface.co/meta-llama/Meta-Llama-3.1-8B-Instruct).localStorage, never transmitted to any backend apart from the official model requests.If a model returns 401/403, the app will surface a helpful message reminding you to accept the license or double-check scopes.
src/tokenizers.ts – core tokenization orchestration, model registry, and display helpers.src/components/ – UI building blocks (SegmentGroup, background visualizations, cards, forms, etc.).src/compare.ts – batch/compare utilities, CSV export, and summary helpers.public/ – static assets, including bundled tokenizer JSON for offline access where possible.o200k and cl100k encoders.Issues and pull requests are welcome! If you spot a tokenizer that should be added, include details on the loading mechanism (Transformers.js vs. Tiktoken) and any license requirements.
This project is open-source under the MIT License. See LICENSE for details.
13 commits
TypeScript
97.7%
HTML
1.2%
Tokenizer Lab is an interactive React + Vite application for exploring how modern multilingual and frontier model tokenizers behave on real text. It lets you inspect token segmentation, compare models side-by-side, and batch-export metrics for downstream analysis without leaving the browser.
␣, tabs to ⇥, and newlines to ⏎.� replacement character, and hex representations are used when decoding is impossible.| Category | Model ID | Display name | Implementation |
|---|---|---|---|
| General purpose | Xenova/bert-base-multilingual-uncased | mBERT (Multilingual BERT) | Transformers.js |
| General purpose | Xenova/t5-small | T5 | Transformers.js |
| General purpose | Xenova/xlm-roberta-base | XLM-RoBERTa | Transformers.js |
| General purpose | Xenova/bert-base-uncased | BERT (English) | Transformers.js |
| General purpose | Xenova/distilgpt2 | DistilGPT‑2 | Transformers.js |
| Indic specialists | ai4bharat/IndicBERTv2-MLM-only | IndicBERT v2 MLM | Transformers.js |
| Indic specialists | InvincibleSloth/muril-tokenizer | MuRIL | Transformers.js |
| Frontier / production | openai/tiktoken/cl100k_base | OpenAI GPT‑4 family (cl100k_base) | Tiktoken WASM |
| Frontier / production | openai/tiktoken/o200k_base | OpenAI GPT‑4o mini (o200k_base) | Tiktoken WASM |
| Frontier / production | anthropic/claude-3-opus-20240229 | Anthropic Claude 3 Opus | Tiktoken WASM |
| Frontier / production | meta-llama/Meta-Llama-3.1-8B-Instruct | Meta Llama 3.1 8B Instruct | Transformers.js |
| Frontier / production | mistralai/Mistral-7B-Instruct-v0.3 | Mistral 7B Instruct v0.3 | Transformers.js |
Note: Meta and Mistral repositories are gated. You must visit their model page on Hugging Face with the same account as your access token and accept the terms before they will load successfully.
Every tokenization run surfaces:
[start, end]) whenever a tokenizer supports them.tokenCountcharCount (grapheme clusters)byteCounttokensPer100CharsbytesPerTokenavgTokenLengthunkPercentageIn Batch mode, the application:
Switching modes preserves your text input so you can iterate without retyping.
Auto mode runs inside a dedicated web worker that samples your pasted lines, applies the selected mutation axes, and streams results back as CSV chunks. You can cancel the worker at any point, keep the streamed rows for inspection, and download the accumulated CSV once a chunk has arrived. The download controls keep the exact config JSON so the provenance embedded in every row stays reproducible.
Numeric sweep axes (ascii_ratio, emoji_count, perturbations) emit numeric x_value entries to make downstream plotting easier.
AutoSweep CSV rows are emitted in the following order:
@radix-ui/themes, clsx, class-variance-authority) for styling.hf object) to load Hugging Face tokenizers in the browser.npm install
npm run dev
Open the printed local URL (typically http://localhost:5173) to load the app.
npm run build
Preview the output with npm run preview.
https://huggingface.co/meta-llama/Meta-Llama-3.1-8B-Instruct).localStorage, never transmitted to any backend apart from the official model requests.If a model returns 401/403, the app will surface a helpful message reminding you to accept the license or double-check scopes.
src/tokenizers.ts – core tokenization orchestration, model registry, and display helpers.src/components/ – UI building blocks (SegmentGroup, background visualizations, cards, forms, etc.).src/compare.ts – batch/compare utilities, CSV export, and summary helpers.public/ – static assets, including bundled tokenizer JSON for offline access where possible.o200k and cl100k encoders.Issues and pull requests are welcome! If you spot a tokenizer that should be added, include details on the loading mechanism (Transformers.js vs. Tiktoken) and any license requirements.
This project is open-source under the MIT License. See LICENSE for details.
13 commits
TypeScript
97.7%
HTML
1.2%