OpenAI Tokenizer: Splitting Text into Tokens

What the OpenAI tokenizer does to your text, what it leaves unchanged, how styled or reversed text affects token counts, and when plain text is the better input.

The OpenAI tokenizer shows how a piece of text is broken into the units that OpenAI language models actually read. People use it to estimate token counts, debug prompts, and understand why some inputs behave unexpectedly. This review covers what the tool changes and what it leaves unchanged. It also explains why stylized, mirrored or reversed text tokenizes poorly, and when plain text is the better input.

Is the tokenizer suitable for what you want to do?

The tokenizer is suitable if your goal is analysis. Use it to see how a model will segment a prompt, to estimate cost or context usage, and to compare how different phrasings or scripts are split. Its main benefit is visibility: it shows the model-side view of text that otherwise looks identical to a human reader.

The tokenizer is not a text transformation for publishing or sharing. Its output is a sequence of numeric token IDs, or a highlighted view of where the boundaries fall. Neither is a readable replacement for the original text. If you need something a person will read, copy, search or hear through a screen reader, keep the plain text and treat tokenization only as a diagnostic step.

The key tradeoff is that token counts depend on the specific encoding. Different OpenAI models have used different encodings, so a count measured with one encoding may not match another model. Check which encoding your target model uses before relying on a number.

What tokenization actually changes

OpenAI models use byte-level byte-pair encoding (BPE). Text is first converted to UTF-8 bytes. The bytes are then merged into larger units according to a vocabulary learned from training data. Frequent sequences, such as common English words or word fragments with a leading space, often become a single token. Rare sequences are split into smaller pieces, down to individual bytes if necessary.

Tokenizing does not rewrite, reorder or restyle your stored text. Encoding and then decoding the full token sequence returns the original string. What the tool adds is a segmentation view and a list of integer IDs. This is different from the transformations that are often grouped under 'text tools':

  • Reversal changes the stored order of characters or words.
  • Mirrored text substitutes look-alike glyphs, or applies a visual flip through CSS without changing the characters.
  • Unicode 'fonts' replace ordinary letters with different code points, such as mathematical alphanumeric symbols.
  • Bidirectional display changes how characters appear on screen without changing their stored order.
  • Tokenization changes none of these. It only describes how the existing characters are segmented for a model.

Tokens do not line up with words, characters, or what a reader perceives as one symbol. One token can be a whole word, part of a word, a space plus a word, or punctuation. A single visible character can span several tokens. This happens with many emoji, emoji built from several code points, and letters with combining marks.

Because the encoding works on bytes, decoding one token in isolation can produce an incomplete UTF-8 sequence. Viewers usually show this as a replacement character. That is a property of the segmentation, not damage to your text.

How script and styling affect token counts

The vocabulary favors sequences that were common in training data. Text in some languages and scripts therefore splits into more tokens per word than typical English prose. If you are working with Cyrillic or other non-Latin text, measure it directly instead of assuming English-like counts. The source material for this review contained no measured ratios, so none are given here.

Stylized and transformed text tends to tokenize much less efficiently than plain text. Unicode 'font' letters, upside-down or mirrored look-alike glyphs, and character-reversed words are uncommon sequences. They are often broken into many small byte-level pieces. This increases token usage and can make the input harder for a model to interpret, even when it looks clear on screen. If the goal is a prompt a model will process reliably, plain text is preferable.

Checking counts yourself

OpenAI publishes an open-source library, tiktoken, that implements its encodings. A minimal check in Python looks like this. Pick the encoding that matches your target model:

import tiktoken

enc = tiktoken.get_encoding("o200k_base")
ids = enc.encode("Splitting text into tokens")

print(len(ids))                       # token count
print([enc.decode([i]) for i in ids]) # each token as text
print(enc.decode(ids))                # round-trips to the original

Running the same check on a plain sentence and on a Unicode-styled or reversed version shows the difference directly. No measured results are reported here, because none were supplied as evidence.

Will the result stay readable and usable after copying or sharing?

Your original text is unaffected. Copying it out of a tokenizer view should give you the same characters you entered. However, whether a particular web interface copies exactly the input, or adds markup or separators, has not been verified here. Check this before relying on it.

Token IDs are not readable text. They mean nothing to people, search engines or assistive technology, and they are only meaningful together with the encoding that produced them. Share them only with tools that will decode them using that same encoding.

Several things remain unverified. No documentation or scoped testing was available on how screen readers handle a color-highlighted token view. It is also unknown whether a given web tokenizer page meets accessibility guidelines. Treat these as open questions rather than assuming support.

Privacy depends on how you run the tokenizer. A locally installed library processes text on your own machine. For any web-based tokenizer, check the provider's published data-handling terms before pasting sensitive content. Do not draw conclusions from how the page looks.

Bottom line

Use the OpenAI tokenizer to understand and measure how a model sees your text, using the encoding that matches your model. It does not change meaning or appearance, so it does not affect readability. Its output simply is not meant to be read. For anything a human or a model needs to read reliably, keep plain text, and avoid stylized, mirrored or reversed characters.