o200k_base Tokenizer

Token count

0

o200k_base is a byte-pair-encoding (BPE) tokenizer from OpenAI's open-source tiktoken library, with a vocabulary of about 200K tokens. Paste text above to see its token count, token ids and how the text is split.

In tiktoken's model name table these names resolve to o200k_base: `gpt-4o`, `gpt-5`, `gpt-5-mini`, `gpt-5-nano`, `gpt-4.1`, `gpt-4.1-mini`, `gpt-4.1-nano`, `gpt-4o-mini`, `chatgpt-4o-latest`, `o1`, `o1-mini`, `o3`, `o3-mini`, `o4-mini`, `gpt-oss-120b`, `gpt-oss-20b`.

gpt-oss models officially use o200k_harmony. It produces the same token ids as o200k_base for ordinary text (checked on more than 1,000 sample texts); only special tokens such as <|start|> and <|channel|> differ.

Token counts for sample texts

TextSampleTokens
EnglishThe quick brown fox jumps over the lazy dog.10
Chinese你好,世界!今天天气很好。9
Codedef add(a, b): return a + b11

FAQ

What is o200k_base?

o200k_base is one of the encodings shipped with OpenAI's tiktoken. It turns text into integer token ids; language models read and are billed by tokens, not characters.

Which models use o200k_base?

According to tiktoken's model name table: `gpt-4o`, `gpt-5`, `gpt-5-mini`, `gpt-5-nano`, `gpt-4.1`, `gpt-4.1-mini`, `gpt-4.1-nano`, `gpt-4o-mini`, `chatgpt-4o-latest`, `o1`, `o1-mini`, `o3`, `o3-mini`, `o4-mini`, `gpt-oss-120b`, `gpt-oss-20b`. Choose any of them in the selector above to see the same encoding.

How do I count o200k_base tokens in code?

With OpenAI's tiktoken, which has Python and JavaScript (WASM) builds:

# Python
import tiktoken
enc = tiktoken.get_encoding("o200k_base")
print(len(enc.encode(text)))

// JavaScript
import { get_encoding } from "tiktoken";
const enc = get_encoding("o200k_base");
console.log(enc.encode(text).length);
enc.free();

Is my text sent to a server?

No. Tokenization runs in your browser and the text never leaves the page. For usage statistics the page only reports which tokenizer you pick and that you started typing, never the text itself.

Why can the count differ from the usage reported by an API?

Chat requests wrap your text in special tokens and per-message formatting that this page does not show. For billing and limits, use the usage field in the API response as the authoritative number.

Related tokenizers