Skip to content

AI Token Counter for ChatGPT, Claude and Gemini

See roughly how many tokens your text uses and what it costs, and split long documents into chunks.

  1. 1Paste your text
  2. 2Check the result
  3. 3Copy or download
OpenAI

GPT-5.6 Terra

454tokens
Est. input cost:$0.00091
Context Window:1.05M tokens
OpenAI

GPT-5.6 Luna

454tokens
Est. input cost:$0.00009
Context Window:1.05M tokens
Anthropic

Claude Sonnet 5

581tokens
Est. input cost:$0.00116
Context Window:1M tokens
Anthropic

Claude Haiku 4.5

454tokens
Est. input cost:$0.00045
Context Window:200K tokens
Google

Gemini 3.1 Pro

454tokens
Est. input cost:$0.00091
Context Window:1M tokens
Google

Gemini 3.5 Flash

454tokens
Est. input cost:$0.00068
Context Window:1M tokens
Open source, hosted

Llama / Qwen (open models)

491tokens
Est. input cost:$0.00010
Context Window:Varies by host

Token counts are estimates based on typical characters per token for each tokenizer. Exact counts can differ by 10 to 20 percent. Prices are standard input rates per provider pricing pages, checked September 2026. Providers change prices often, so confirm before budgeting.

Document Input
Characters: 1,815Words: 227Headings: 6

RAG Semantic Chunker1 Chunk Generated

Break document by token limit for embedding models (e.g. OpenAI text-embedding-3, Gemini Embeddings)

#1Chunk 1 (4. Conclusion & Next Steps)
~524 tokens (1815 chars)
# Scalable Retrieval-Augmented Generation (RAG) Architecture
**Authors:** Dr. Jane Doe, Alex Rivera  
**Published:** September 2026

## 1. Executive Summary
Retrieval-Augmented Generation bridges proprietary enterprise knowledge with large language model generation. By injecting vector-ranked document chunks into inference context windows, organizations avoid costly model fine-tuning while reducing hallucination rates by over 68%.

### Key System Characteristics:
- **Zero-Latency Ingestion:** Local client-side parsing eliminates server queues.
- **Dynamic Chunking:** Token-aware boundaries preserve section headings.
- **Multimodal Embedding:** Support for Markdown tables, code snippets, and structured equations.

## 2. Technical Comparison Matrix

| System Component | Traditional Full Fine-Tuning | In-Browser RAG Extraction |
| :--- | :---: | :---: |
| Latency to First Token | High (>1.5s) | Sub-100ms |
| Data Privacy Compliance | Cloud Dependent | 100% Client-Side Local |
| Context Window Utilization | Fixed Weights | Dynamic (128k - 2M tokens) |
| Running Cost | $$$$ GPU Training | $0 Free Compute |

## 3. Implementation Code Example

```python
import os
from google.genai import GoogleGenAI

def generate_contextual_answer(query: str, retrieved_markdown: str):
    client = GoogleGenAI(api_key=os.environ["GEMINI_API_KEY"])
    prompt = f"""Use the following markdown document to answer the user request:
    ---
    {retrieved_markdown}
    ---
    Question: {query}"""
    
    response = client.models.generate_content(
        model="gemini-1.5-flash",
        contents=prompt
    )
    return response.text
```

## 4. Conclusion & Next Steps
By converting legacy enterprise documents into standard Markdown formats, developer teams gain full observability and deterministic token tracking.

How to count tokens and chunk a document

  1. Paste your text or Markdown into the document box.
  2. Read the estimated token count and input cost for each model in the cards above.
  3. Set a chunk size and overlap, then copy chunks one by one or export them all as JSON for your vector database.

What a token is

Language models read text in tokens, which are pieces of words. In English one token is roughly four characters, or about three quarters of a word. Other languages such as Bangla, Hindi or Chinese usually need several times more tokens for the same meaning, and the counter accounts for that.

Each provider uses its own tokenizer, so the same text gives slightly different counts. Newer Claude models, for example, produce noticeably more tokens for the same English text than GPT models.

Choosing a chunk size for RAG

For retrieval, 300 to 800 tokens per chunk with 10 to 15 percent overlap is a common starting point. Smaller chunks give more precise matches, larger ones keep more context. Keeping the section heading on each chunk helps the model know where the text came from.

Frequently asked questions

How accurate are the counts?

They are estimates, usually within 10 to 20 percent for English prose. Code, tables and non-English text vary more. For exact billing numbers, use the provider's own token counting API.

Are the prices up to date?

They are the standard input prices per million tokens as listed by each provider when the page was last updated. The date is shown under the model cards. Output tokens cost more and are not included.

Is my text sent to OpenAI, Anthropic or Google?

No. Counting happens in your browser. No AI service is called.

Did a file convert badly or something not work? Report a problem. Your files are never uploaded, so a sample file helps us fix it.