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.
Prompt Text
0 charactersExpected 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.
Related Products
on GumroadAI Prompt Engineering Toolkit
58 structured prompt templates for Claude, ChatGPT, and Gemini — organized by use case. Code Review, Debugging, Documentation, Architecture, and 10 model-specific tips. Stop writing prompts from scratch.
Buy on Gumroad →AI Developer Prompts Pack
55 battle-tested prompt templates for the workflows developers actually use: code review, debugging, architecture, documentation, and testing. Stop writing prompts from scratch.
Buy on Gumroad →Developer Productivity Bundle
Stop rebuilding the same setup every project. 51 VSCode snippets, 40 Git aliases, 5 Docker Compose stacks, 5 GitHub Actions workflows, 5 README templates, and a dotfiles kit. Set up a professional dev environment in under an hour.
Buy on Gumroad →You Might Also Need
AI Prompt Cost Calculator
Calculate daily and monthly API costs for GPT-4o, Claude 3.5, Gemini 1.5, and more. Enter token counts, model, and request volume to get instant cost projections.
Open free tool →
OpenAI Prompt Tester
Score your AI prompt quality across 7 dimensions: role definition, task clarity, output format, constraints, examples, tone, and error handling. Get actionable improvement suggestions.
Open free tool →
LLM System Prompt Analyzer
Analyze your LLM system prompt completeness. Checks 10 dimensions: persona, task clarity, output format, constraints, tone, examples, context, error handling, audience, and success criteria.
Open free tool →
More Free Tools
Related Articles
LLM Token Optimization: Reduce API Costs by 60%
Practical techniques to dramatically reduce LLM API costs: token counting, prompt compression, caching strategies, model routing, and batching. Real examples with before/after token counts and cost analysis.
OpenAI Agents SDK vs Claude API vs Gemini: Building Production AI Agents 2026
Complete comparison of OpenAI Agents SDK, Claude API, and Gemini for production AI agents in 2026. Multi-agent workflows, tool use, streaming, cost, tracing, and when to use each.
Prompt Engineering Techniques 2026: Chain-of-Thought, RAG, and Advanced Patterns
Advanced prompt engineering guide for 2026: Chain-of-Thought, Tree-of-Thought, RAG integration, few-shot learning, prompt chaining, and evaluation techniques.
Vercel AI SDK: Complete Guide to Streaming, Tool Calling & Multi-Provider in 2026
Master the Vercel AI SDK in 2026. Streaming text and objects, tool calling, multi-provider support (OpenAI, Claude, Gemini), agents, and production patterns. TypeScript-first guide.
Claude API Complete Guide for Developers 2026: Models, Pricing & Best Practices
Complete guide to the Claude API in 2026. Covers model lineup, TypeScript and Python integration, system prompts, tool use, vision, prompt caching, extended thinking, batch processing, and production patterns.
Enjoying this tool? Get more like it.
Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.
Unlock AI-Powered Dev Tools
- ⚡ AI Code Review, Doc Generator & SQL Builder
- ⚡ All premium templates & early access
- ⚡ Member discounts on Gumroad products
$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.
MIT licensed · Instant download · No subscription
See what's included → Browse all deals →