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.
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.
- Extract the text, in your browser.PDFs are read with Mozilla's pdf.js (the page text layers are concatenated); Word
.docxfiles 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. - Count tokens per model family.For OpenAI models the count is exact: the tool runs tiktoken's
o200k_basetokeniser (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. - 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. - Price the input. Input cost is
tokens ÷ 1,000,000 × inputPricePerMillion. Adding an expected reply length addsoutputTokens ÷ 1,000,000 × outputPricePerMillionfor 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
Frequently asked questions
Sources & references
- OpenAI tiktoken — the o200k_base / cl100k_base BPE tokenisers (exact GPT counts)
- Anthropic — token-counting guidance (~3.5 English chars per token)
- Google Gemini API — tokenisation docs (~4 chars per token)
- DeepSeek — token usage (1 English char ≈ 0.3 token)
- OpenAI API pricing — per-million input/output token prices
- Anthropic (Claude) pricing
- Google Gemini API pricing
- Central Bank of Sri Lanka — daily indicative USD→LKR rate
Tokenisation ratios and the model roster were last verified on 2026-07-11. Per-model prices are maintained in the shared AI API Cost Calculator dataset and reviewed quarterly.
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.