Local code token tool

Code Token Counter

Paste source code and compare how seven tokenizers count it. Use an example or enter code in any language.

Editable sample

Compare code token counts

Every tokenizer receives the exact source code in the editor. Language selection only changes the starter example.

Characters
178
Lines
6
Or replace the example with any code.
Initial benchmark result

Tokenizer files load only after you run a comparison. Your text stays in this browser.

TokenizerTokensTokens / lineDifference from OpenAI Current
OpenAI Currento200k_base457.5Same as baseline
OpenAI Legacycl100k_base457.5Same as baseline
Gemma 3Pinned SentencePiece model569.3+11 (+24.4%)
DeepSeek V4 ProPinned tokenizer JSON457.5Same as baseline
Qwen 3.5Pinned tokenizer JSON538.8+8 (+17.8%)
Mistral Medium 3.5Pinned tokenizer JSON498.2+4 (+8.9%)
Llama 3Pinned tokenizer JSON457.5Same as baseline
Code files

Need to count a complete file?

Use the file token counter to load TypeScript, Python, Go, Java, Rust, SQL, Astro, and other text-based code files locally.

Use the JSON token counter when you need to compare formatted and minified payloads.

View tokenizer sources
How StackLens verifies data and calculates cost

OpenAI Current tokenizer sourceHigh confidenceChecked 2026-07-19

Code is encoded locally with o200k_base; syntax highlighting, chat wrappers, and API message formatting are not added.

OpenAI Legacy tokenizer sourceHigh confidenceChecked 2026-07-19

Code is encoded locally with cl100k_base; syntax highlighting, chat wrappers, and API message formatting are not added.

Gemma 3 tokenizer sourceHigh confidenceChecked 2026-07-19

Code is encoded locally with Pinned SentencePiece model; syntax highlighting, chat wrappers, and API message formatting are not added.

DeepSeek V4 Pro tokenizer sourceHigh confidenceChecked 2026-07-19

Code is encoded locally with Pinned tokenizer JSON; syntax highlighting, chat wrappers, and API message formatting are not added.

Qwen 3.5 tokenizer sourceHigh confidenceChecked 2026-07-19

Code is encoded locally with Pinned tokenizer JSON; syntax highlighting, chat wrappers, and API message formatting are not added.

Mistral Medium 3.5 tokenizer sourceHigh confidenceChecked 2026-07-19

Code is encoded locally with Pinned tokenizer JSON; syntax highlighting, chat wrappers, and API message formatting are not added.

Llama 3 tokenizer sourceMedium confidenceChecked 2026-07-19

Code is encoded locally with Pinned tokenizer JSON; syntax highlighting, chat wrappers, and API message formatting are not added.

FAQ

Code token counter questions

Which programming languages can I count?

You can paste any plain-text source code. The TypeScript, Python, Go, and SQL options load examples only; they do not change or estimate the tokenizer result.

Does formatting affect code token count?

Yes. Indentation, whitespace, comments, identifiers, punctuation, and line breaks are part of the code string sent to each local tokenizer.

Is my source code uploaded?

No. The listed tokenizers run in your browser. Avoid pasting credentials, private keys, or proprietary source into any online tool.

Does fewer tokens mean a model is better at code?

No. This page compares tokenization only. It does not measure code quality, reasoning, latency, or model performance.