LLM Token Calculator

Estimate token counts for any text or code, compare token-to-cost across 40+ models, and get prompt optimization suggestions to reduce your API bill. Supports word, character, and code-aware estimation modes.

Text + Code Live Cost Optimization Multi-currency
Loading…

Enter Your Text

Code uses ~3.5 chars/token; text uses ~4 chars/token
Token Estimate

Cost Across Models (per request)

Token Estimation Reference

Content TypeTokens / WordTokens / CharacterExample
English prose~1.3~0.25"Hello world" = 2 tokens
Code (Python/JS)~1.5~0.29"def foo():" = 5 tokens
Non-English (Hindi, Japanese)~2.0~0.5More tokens per character
JSON / structured data~1.4~0.27Keys + values each tokenize
Markdown with code blocks~1.4~0.28Mixed text + code

Rules of Thumb

Prompt Optimization Suggestions

When you click "Estimate", the calculator analyzes your text and suggests ways to reduce token usage. Common savings:

FAQ

How many tokens is 1000 words?

Approximately 1,330 tokens. The rule of thumb is 1 word ≈ 1.33 tokens, or 1 token ≈ 0.75 words (4 characters). For code, expect ~1,500 tokens per 1000 words.

How are tokens counted?

Tokens are sub-word units produced by a tokenizer (BPE for GPT, SentencePiece for Llama). Common words are 1 token; rare words split into multiple tokens. Code and non-English text use more tokens per character because they contain more unique sub-words.

Is this estimator exact?

No — it's a close approximation. Exact token counts require the provider's tokenizer (tiktoken for OpenAI). This estimator is within ±10% for English text and ±15% for code. For production billing, always use the actual tokenizer.

How do I reduce token usage?

Remove politeness filler, limit few-shot examples to 2, compress multi-line context into bullets, use prompt caching for static prefixes, and right-size your model (use a nano model for classification, a flagship only for complex reasoning).

Why do code and non-English text use more tokens?

Tokenizers are trained mostly on English prose. Code contains many unique sub-words (operators, identifiers), and non-English languages have different character sets that split into more tokens per character.