Free LLM token calculator: paste text to count tokens with tiktoken-style encodings (cl100k_base, o200k_base) or a fast approximate rule (UTF-8 bytes ÷ 4). See words, characters, and illustrative USD estimates for input and expected output tokens. Token visualization shows how the text splits into pieces (with preview / expand limits). Compare costs table pits illustrative rates across models. No server round-trip for counting — runs in the browser; localStorage persists your draft (spoold-token-calculator). Not a billing quote — confirm pricing with your provider.
Live tool: spoold.com/tools/token-calculator
- What this tool is for
- Who searches for this (keywords)
- Features
- How to use
- Rules, limits & disclaimers
- Related tools
- Tech stack
- Repository
Use this online token counter when you need to:
- 📏 Estimate prompt size before calling an API (especially when your stack uses OpenAI-style tokenization).
- 🔄 Compare cl100k vs o200k counts on the same text (models and APIs differ).
- 💵 Ballpark cost from illustrative $/1M input and output rates plus an expected output token count.
- 🎨 See token boundaries in the text via the visualization (helpful for debugging long prompts).
Part of Spoold — web and developer utilities in one place.
llm token calculator, token counter online, gpt token counter, openai token calculator, tiktoken calculator, cl100k token counter, o200k tokenizer, prompt token calculator, token cost estimator, characters to tokens, chatgpt token calculator.
| Area | What you get |
|---|---|
| 🔤 Tokenizers | Approximate (bytes ÷ 4), cl100k_base, o200k_base via js-tiktoken (exact modes load on the client). |
| 📊 Stats | Token count, word count, characters (with / without spaces). |
| 💰 Cost estimate | Dropdown of illustrative model rates ($/1M in & out) plus Custom fields; expected output tokens for output-side estimate. |
| 🌈 Visualization | Colored token pieces; preview cap with show all up to a hard max (see limits). |
| ⚖️ Compare costs | Side-by-side illustrative totals for multiple models from the same input/output assumptions. |
| 💾 Persistence | localStorage key spoold-token-calculator saves text, tokenizer, model selection, custom rates, and expected output tokens. |
| 📖 Guide | On-page SEO/guide section (#token-calculator-guide) for deeper context. |
- Open Token calculator & cost.
- Choose Tokenizer (approx, cl100k, or o200k).
- Optionally pick a Model for the $ estimate (or Custom and edit $/1M).
- Set Expected output tokens if you want an output cost line.
- Paste or type text in the editor; read tokens, cost summary, visualization, and compare table.
- 💻 Client-only counting: Exact tiktoken encodings run in the browser; there is no dedicated API for token counts in this tool.
- 🔢 Visualization caps: Piece list is shown in preview up to 400 tokens by default; expanding uses the same pipeline capped at 8000 tokens (
TOKEN_LIST_VIZ_PREVIEW/TOKEN_LIST_HARD_MAXin@/lib/token-budget-count). - ⚡ Approximate mode: Not equivalent to provider billing; useful for quick mental math.
⚠️ Prices: All $/1M values are illustrative (@/lib/token-calculator-pricing). Always verify current pricing on the vendor’s site.
- Token & context budget — Split prompt into system / user / RAG / extra and check against a context window (same tokenizer modes).
- LLM RAM / VRAM — GPU memory planning.
- Token speed simulator — Throughput / latency feel.
- Next.js App Router — page at
src/app/tools/token-calculator/page.tsx, UI intoken-calculator-client.tsx. - js-tiktoken for cl100k_base / o200k_base encoding (shared helpers in
@/lib/token-budget-count). - React client components for editor, visualization, and compare panel.
github.com/thespoold/spoold — pnpm install && pnpm dev, then open /tools/token-calculator.
Spoold — Paste. Detect. Do. · spoold.com