Counting tokens for Grok
Grok 4 loads by default; add any other model from the compare table to see the same text priced elsewhere. The count updates as you type, along with the input cost and the share of Grok's million-token context window your text fills. Nothing is uploaded: the vocabulary is downloaded once and the text is tokenized locally.
Pricing and context windows
Grok's input price per million tokens, with its context window.
| Model | Tokenizer | Price / 1M input | Context window |
|---|
| Grok 4 | grok-2 | $1.25 | 1M |
Prices and context windows are curated metadata refreshed periodically from the providers and OpenRouter, so treat them as guidance rather than a quote. Token counts are always produced by the real tokenizer.
How Grok tokenization works
Grok uses a byte-level BPE vocabulary released by xAI, with one detail approximated here. xAI publishes the vocabulary in its own format, which this tool converts to a standard tokenizer file offline. The vocabulary itself is exact; the pre-tokenizer regex that decides where words are split before merging is not published, so it is reconstructed as a close approximation.
In practice that puts Grok among the most compact vocabularies we measure: in our fixed 500-word English sample it produced the lowest token count of any family in the tool.
Frequently asked questions
Is this xAI's official tokenizer?
The vocabulary is xAI's; the word-splitting rule in front of it is approximated. xAI releases the vocabulary but not the pre-tokenizer regex, so this tool reconstructs it. Counts are accurate on ordinary text and can differ marginally on unusual formatting.
Which Grok models does this cover?
Grok 4, using the vocabulary shared across current Grok releases. Because the vocabulary is shared, the count applies to Grok variants that are not listed individually. Only price and context window would differ.
How do Grok counts compare with GPT?
Marginally lower on English prose. Our measured 500-word sample came to 571 tokens with Grok's vocabulary against 572 with OpenAI's o200k_base. The two are close enough that a prompt budget carries over directly.