Token Counter

Text & Code

Count tokens accurately with BPE tokenizers and calculate costs for GPT-4o, Claude 3.5 Sonnet, and Gemini models.

Presets:

OpenAI Tokens

50

Words

41

Characters

318

Lines

3

Estimated Costs & Token Comparison Across Models

Updated rates (per 1M tokens)
ModelProviderEst. TokensInput CostOutput Cost (1x)
GPT-4o (Omni)OpenAI50$0.000125$0.000500
GPT-4o miniOpenAI50$0.000008$0.000030
Claude 3.5 SonnetAnthropic54$0.000162$0.000810
Claude 3.5 HaikuAnthropic54$0.000043$0.000216
Gemini 1.5 ProGoogle52$0.000065$0.000260
Gemini 1.5 FlashGoogle52$0.000004$0.000016

Exact tokenization for OpenAI models uses the official byte-pair encoding (BPE) cl100k/o200k algorithm in your browser. Claude and Gemini token counts use calibrated tokenizer ratios. All text remains strictly inside your local browser memory.

How to Use Token Counter

  1. 1Step 1

    Paste your prompt, markdown article, source code, or JSON payload into the input editor.

  2. 2Step 2

    Review the real-time token total, character count, and word count cards.

  3. 3Step 3

    Examine the model comparison table to evaluate estimated input and generation costs.

  4. 4Step 4

    Click Copy to reuse your verified prompt or Clear to begin a new calculation.

Technical Specification & Client Security

Tokenization relies on client-side BPE lookup dictionaries compiled for web runtime. Multi-model cost estimates reflect standard API pricing per million tokens without sending network requests.

›Exact BPE tokenization using native WebAssembly and client-side BPE lookup
›Real-time cost comparison across GPT-4o, Claude 3.5 Sonnet, and Gemini 1.5 Pro
›Instant character, word, and line count breakdown
›Preloaded templates for system prompts, code snippets, and JSON payloads
›100% private in-browser analysis without external API telemetry
›Fast copy and reset actions with visual feedback

Input & Output Transformation Examples

System Prompt Token Estimation
Input:
You are an autonomous AI assistant specialized in developer tooling. Always output clean TypeScript without telemetry.
Output:
Tokens: 21 | Characters: 116 | Words: 16 | Estimated GPT-4o Input Cost: $0.000052
API Payload JSON Chunk
Input:
{
  "status": "success",
  "data": [1, 2, 3, 4, 5]
}
Output:
Tokens: 19 | Characters: 47 | Words: 8 | Estimated Claude 3.5 Sonnet Cost: $0.000057

Frequently Asked Questions

How does this token counter calculate OpenAI tokens?

The counter uses client-side Byte-Pair Encoding (BPE) identical to OpenAI tiktoken (cl100k_base and o200k_base), providing exact token counts for GPT-4o, GPT-4, and ChatGPT models directly in your browser.

Are Anthropic and Gemini token counts accurate?

OpenAI tokens are calculated exactly via native BPE. For Claude and Gemini, we apply statistically calibrated tokenization multipliers derived from comparative multi-lingual corpus benchmarks, giving precision within 2-3%.

Is my prompt or sensitive payload sent to any server?

No. Computation executes completely inside your browser using client-side JavaScript. No tokens, prompts, or API keys are ever transmitted over the network.

Related Developer Utilities