LLM Token Counter
Count tokens and estimate cost for GPT, Claude, Gemini and Llama prompts, with exact counts where tokenizers are public.
Turn Markdown docs into clean chunks for retrieval-augmented generation. Each document is split at its headings into token-sized pieces, with the heading path and front matter kept as metadata, ready to embed or upload.
Add Markdown to build a knowledge base
Upload docs, notes or a README. Each one is split at its headings into chunks sized for embeddings, with the heading path and front matter kept as metadata.
How it works
Upload one or more Markdown files, or paste a document. Load the sample to see how it works.
Choose the maximum chunk size and overlap. 300–800 tokens suits most embedding models.
Review the chunks: each shows its heading path and token count, and expands to the full text.
Pick an export format and download it, or copy it into your pipeline.
About this tool
Retrieval-augmented generation finds the most relevant pieces of your documents and gives them to a model as context. Those pieces are chunks, and how you cut them matters: chunks that are too big bury the answer in unrelated text, chunks that are too small lose the context that makes them meaningful, and cuts in the middle of a code block or a list produce fragments nobody can use.
This tool splits along the structure Markdown already has. Chunks never cross a heading, paragraphs, lists, tables and code blocks stay whole where they fit, and oversized ones are split at sentence boundaries. Each chunk can start with its heading path (Guide > Install > Windows) so it stands on its own, optionally overlaps the previous chunk, and carries the file name and front matter as metadata. Token counts use the GPT-4o tokenizer, which is close to most embedding models' limits.
Chunks follow your document's sections and keep code blocks, lists and tables intact.
Sized with the GPT-4o (o200k) tokenizer, with a configurable limit and overlap.
Source file, title, heading path, chunk index and front matter on every chunk.
Export JSONL, JSON or CSV for vector databases, or one Markdown file for custom GPTs and projects.
FAQ
Start around 500 tokens with 10% overlap. Smaller chunks (200–300) suit precise Q&A over reference docs; larger ones (800–1,500) suit narrative text where context matters. Test retrieval on real questions and adjust.
A chunk like "Run the installer and restart" is ambiguous on its own. With "Guide > Install > Windows" in front, both the embedding and the model know what it's about.
A little overlap keeps sentences that span a boundary findable from either chunk. Because this tool already splits at headings and paragraphs, 10–15% is usually enough.
They're exact for OpenAI's current models and close for most others, since modern tokenizers produce similar counts for English text. Leave some headroom below your model's hard limit.
No. Chunking and token counting run entirely in your browser, and your files never leave your device.
Missing something?
Describe the job and the file types involved. The most requested tools get built first.