Skip to content
induwara.lk
induwara.lkAI · Developer tools

AI Document Token & Cost Calculator

Drop a PDF, Word or text file and see its exact token count, whether it fits in each model's context window, and what it costs to send to GPT-5, Claude, Gemini, Llama and more, in USD and rupees. Parsed entirely in your browser: no upload, no API key, no signup.

By Induwara AshinsanaUpdated Jul 11, 2026
Document token & cost
100% in-browser · no upload

Parsing runs locally in your browser, nothing is uploaded to any server.

What this does

Drop a document (or paste text) and this tool counts the exact input tokens, shows what it costs to send to GPT-5, GPT-4o, Claude, Gemini, Llama, DeepSeek and Mistral in USD and rupees, and tells you whether it fits in one call. No signup, no API key.

Optional, adds the model's output cost to the total.

CBSL indicative default, edit to today's rate.

Show cost in

The table always shows both.

Models to compare

GPT token splits use gpt-tokenizer (a browser port of OpenAI's tiktoken). Prices and context sizes come from the maintained AI API Cost Calculator dataset. Claude/Gemini/Llama/DeepSeek/Mistral counts are documented estimates, see the methodology and sources below.

How it works

This tool answers one question the paste-text token counters can't: "I have a file, what will it cost to run through each model, and will it fit?" It combines client-side file parsing, real tokenisation, maintained pricing, and context-window fit in one place. Nothing you upload leaves your device.

  1. Extract the text, in your browser.PDFs are read with Mozilla's pdf.js (the page text layers are concatenated); Word .docx files are unzipped with JSZip and the document body is stripped from its XML; plain text, Markdown, CSV, JSON and source code are read directly as UTF-8. Scanned PDFs with no text layer are flagged, not guessed.
  2. Count tokens per model family.For OpenAI models the count is exact: the tool runs tiktoken's o200k_base tokeniser (via gpt-tokenizer), the same byte-pair encoding OpenAI bills with. Claude, Gemini, Llama, DeepSeek and Mistral use each vendor's published character-per-token ratio: ~3.5 chars/token for Claude, ~4 for Gemini/Llama/Mistral, and ~3.33 for DeepSeek. Those rows are labelled an estimate.
  3. Check context-window fit.A document fits in one call when its token count is at or below the model's context window. If it doesn't, the number of chunks is ceil(tokens / (contextWindow − 4096)), reserving 4,096tokens of each window for the model's reply.
  4. Price the input. Input cost is tokens ÷ 1,000,000 × inputPricePerMillion. Adding an expected reply length adds outputTokens ÷ 1,000,000 × outputPricePerMillion for the total. Every USD figure is converted to LKR with your rate.

Prices, context-window sizes and the default exchange rate are reused from this site's maintained AI API Cost Calculator dataset, where every per-million figure carries an inline source URL. The arithmetic is cross-checked by an independent per-thousand-token formula and a set of hand-computed worked examples that must reconcile before release, the same verification approach as the tax calculator.

Worked examples

A 42-page contract PDF (~18,000 words ≈ 24,000 tokens)

  1. Extract text from the PDF → 24,000 GPT tokens (exact, o200k_base).
  2. GPT-5 input: 24,000 ÷ 1,000,000 × $1.25 = $0.0300 = Rs 9.00
  3. GPT-4o input: 24,000 ÷ 1,000,000 × $2.50 = $0.0600 = Rs 18.00
  4. Claude Sonnet input: 24,000 ÷ 1,000,000 × $3.00 = $0.0720 = Rs 21.60
  5. Gemini 2.5 Flash input: 24,000 ÷ 1,000,000 × $0.30 = $0.0072 = Rs 2.16
  6. Fit: 24,000 ≤ every window (all ≥ 128k) → single call on all. Cheapest: Gemini Flash.

A 250,000-token research corpus (many files)

  1. Combined text tokenises to 250,000 tokens.
  2. GPT-4o input: 250,000 ÷ 1,000,000 × $2.50 = $0.6250 = Rs 187.50
  3. GPT-5 input: 250,000 ÷ 1,000,000 × $1.25 = $0.3125 = Rs 93.75
  4. Fit vs GPT-4o's 128k window: ceil(250,000 ÷ (128,000 − 4,096)) = ceil(2.02) = 3 chunks.
  5. GPT-5 (400k) and Claude Sonnet (1M) take it in a single call.

Edge case, a scanned PDF, then a boundary check

  1. A scanned PDF has no text layer → 0 tokens extracted, file flagged for OCR (no silent guess).
  2. Boundary: a document of exactly 128,000 tokens fits GPT-4o's 128k window → 1 call.
  3. One token more (128,001) no longer fits: ceil(128,001 ÷ 123,904) = 2 chunks.
  4. Zero-length input costs $0.00 on every model, no NaN, no divide-by-zero.

Frequently asked questions

Sources & references

Related tools

Comments & feedback

Spotted a bug or want an improvement? Tell us, our team reviews every comment, and good ideas get built. Comments are public and anonymous.

Found a bug, edge case, or want another file type supported?

Email me at [email protected] , most fixes ship within 24 hours.