Skip to main content

Prompt Token Counter

Count tokens in your prompt and estimate API costs for GPT-4o, Claude, and Gemini models. Paste your text to see token counts and pricing breakdown.

✓ Real-time token counting ✓ Cost per model ✓ Context window check

Prompt Text

0 characters
0
Input Tokens
0
Words
0
Lines
0
Tok/Word ratio

Expected Output Size

Cost by Model

Model Input $/1M Output $/1M Context Input Cost Total Cost

Prices are approximate and may change. Check provider pricing pages for current rates.

Frequently Asked Questions

How are tokens counted for LLMs?▼

Tokens are chunks of text that LLMs process — typically 3-4 characters per token in English. Words like 'hello' are usually 1 token; longer words like 'programming' may be 2. Whitespace and punctuation are separate tokens. Non-English text, code, and special characters often use more tokens per word. OpenAI uses tiktoken (BPE), Claude uses a similar approach, Gemini uses SentencePiece.

Why does token count affect cost?▼

LLM APIs charge per token (input + output tokens). Input tokens (your prompt) are typically cheaper than output tokens (the response). A 1M token context Gemini query at 1M input tokens costs around $1.25, while GPT-4o at the same would cost $2.50. Counting tokens before sending helps predict and control costs.

What is the difference between input and output tokens?▼

Input tokens are everything you send: system prompt + conversation history + current user message. Output tokens are what the model generates. For cost estimation, you must count both. Output tokens are usually 2-4x more expensive per token. A typical chat message might be 200 input tokens and generate 400 output tokens.

How does context window size affect my application?▼

The context window is the maximum tokens the model can process at once (input + output combined). GPT-4o has 128K tokens, Claude 3.5 Sonnet has 200K, Gemini 1.5 Pro has 1M. If your conversation history + prompt exceeds the window, you must truncate history. At $0.002/1K tokens, a full 128K context costs $0.26 per call.

How accurate is this token counter?▼

This tool uses an approximation: ~4 characters per token for English text, with adjustments for code, numbers, and punctuation. For precise counts, use the official tokenizers: tiktoken (pip install tiktoken) for OpenAI models, or the model's API to count tokens before sending. The estimates here are typically within 5-10% accuracy.

Share this tool: X / Twitter LinkedIn
✓ 60,000+ developers use DevPlaybook ★★★★★ 4.8 / 5 on Gumroad ✓ MIT licensed · Instant download ✓ No login required

Related Products

on Gumroad

You Might Also Need

More Free Tools

Enjoying this tool? Get more like it.

Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.

DevPlaybook Pro 7 days free

Unlock AI-Powered Dev Tools

  • ⚡ AI Code Review, Doc Generator & SQL Builder
  • ⚡ All premium templates & early access
  • ⚡ Member discounts on Gumroad products
Start Free Trial →

$9/mo after trial · Cancel anytime

Want the full toolkit?

Get DevPlaybook Pro

Every template, guide, boilerplate, and automation script in one bundle. 13 premium products — grab them all at once and save big.

$79
$241 separately Save $162 (67% off)
Get DevPlaybook Pro — $79 →

MIT licensed · Instant download · No subscription

See what's included → Browse all deals →