Online Token Calculator

Quickly estimate the number of LLM tokens and API call costs. Supports mainstream models such as GPT-4o, Claude, DeepSeek, Gemini, and Qwen, and includes pricing for both cache hits and misses.

📋 Common Templates:
📝 Enter text
📊 Real-time Statistics
0
Token (Estimated)
0
Number of characters
0
Word Count
0
Number of lines
0
Number of Sentences
0
UTF-8 bytes
Token Distribution
0%
0%
0%
0%
0%
Chinese English Numbers Punctuation Space
Token Visualization Coloring (Chinese = Red, English = Blue, Numbers = Green, Punctuation = Yellow)
After you enter text, the token highlighting will be displayed here...
💰 API Cost Estimate
(Set to 0 to calculate only the input costs)
Model Enter Price / 1M Token Output Price / 1M Context Occupancy Cost Estimate Operations

What is a token?

A token is the smallest unit of text processed by a large language model, falling between a character and a word. In English, a common word typically corresponds to about 1 token; in Chinese, each character corresponds to approximately 1.5 to 2 tokens.

Calculation formula:

T = Number of Chinese characters × 1.5 + Number of English letters ÷ 4 + Number of digits ÷ 2 + Number of punctuation marks × 0.5

Note:This is an approximate estimate; the actual number of tokens varies depending on the tokenizer used by each model (e.g., GPT-4o uses o200k_base, while Claude uses the Anthropic Tokenizer). Cost estimates are for reference only; actual costs are subject to the API provider’s billing.

Instructions for Use:

  • Supports custom models: Click “+ Add Model” to enter custom model parameters (name, pricing, context window).
  • All prices are editable: Double-click a price in the table to edit it directly.
  • Price Difference Between Cache Hits and Misses: Models such as DeepSeek have very low cached prices; please select based on your actual API call volume.
  • Expected Output Tokens: Set the number of output tokens generated by the API call. Total fee = Input fee + Output fee
  • USD/CNY Dual Currency: Supports one-click switching between U.S. dollars and Chinese yuan; DeepSeek uses Chinese yuan for pricing
  • All data processing is performed locally in the browser and is not uploaded to any server.

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏