Skip to content

spoold-com/token-calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 

Repository files navigation

🧮 Token calculator & cost — LLM token counter (cl100k / o200k / approx)

Open tool Site Free Sign-up

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


📑 Table of contents


🎯 What this tool is for

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.


🔎 Who searches for this (keywords)

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.


✨ Features

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.

👣 How to use

  1. Open Token calculator & cost.
  2. Choose Tokenizer (approx, cl100k, or o200k).
  3. Optionally pick a Model for the $ estimate (or Custom and edit $/1M).
  4. Set Expected output tokens if you want an output cost line.
  5. Paste or type text in the editor; read tokens, cost summary, visualization, and compare table.

⚙️ Rules, limits & disclaimers

  • 💻 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_MAX in @/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.

🔗 Related tools


🛠️ Tech stack

  • Next.js App Router — page at src/app/tools/token-calculator/page.tsx, UI in token-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.

🐙 Repository

github.com/thespoold/spooldpnpm install && pnpm dev, then open /tools/token-calculator.


SpooldPaste. Detect. Do. · spoold.com

About

Token calculator & cost — LLM token counter

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors