Skip to main content

GPT-Tokenizer

A terminal-based GPT token visualiser. Type text into an interactive REPL and each token is printed on a colored background so you can see exactly where the tokenizer splits your input. Backed by tiktoken.

Install

Requires Python 3.10+.

python -m venv .venv
source .venv/bin/activate
pip install -e .

Usage

gpt-tokenizer          # console entry point
# or
python -m gpt_tokenizer

Type text at the prompt and press Enter to tokenize it. To write multiple lines or paragraphs, press Shift+Enter (or Option/Alt+Enter) to insert a newline without submitting — the whole block is tokenized together. Press Ctrl-D to quit.

Shift+Enter relies on your terminal reporting it as a distinct key (iTerm2, kitty, WezTerm, and the VS Code terminal do; macOS Terminal.app does not). Option/Alt+Enter works everywhere.

A line on its own starting with / is a command (runs on Enter):

Command Action
/model Switch model (gpt2, gpt-3.5-turbo, gpt-4, gpt-4o)
/clear Clear the screen and redraw the banner
/help Show the command list
/bye Exit (or Ctrl-C, or Ctrl-D on an empty prompt)

Newlines in your text are shown as a dim ⏎ glyph so the original layout stays visible. The default model is gpt-4o.

Project layout

src/gpt_tokenizer/     Installable package
  cli.py               REPL loop and command dispatch
  tokenizer.py         tiktoken encode wrapper -> list of (id, bytes)
  models.py            Supported models + interactive selection
  render.py            Banner and colorized token output
  ansi.py              ANSI escape-sequence helpers
examples/
  bpe_from_scratch.py  Standalone, educational BPE walkthrough (Karpathy minbpe style)
data/                  GPT-2 encoder.json / vocab.bpe (used only by the example)
tests/                 pytest suite

Development

pip install -e ".[dev]"      # installs pytest
pytest

pip install -e ".[examples]" # installs regex, needed by the BPE example
python examples/bpe_from_scratch.py

Metadata

Release files for gpt-tokenizer 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gpt-tokenizer 1.0.0
File Size Uploaded Provenance
gpt_tokenizer-1.0.0.tar.gz 566.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for gpt-tokenizer 1.0.0
File Interpreter ABI Platform
gpt_tokenizer-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 574.0 kB

Release files / gpt_tokenizer-1.0.0.tar.gz

Download URL gpt_tokenizer-1.0.0.tar.gz
Size 566.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2685646fd07391cb71662c95a75d3c1c2850c8f22132ac5f0092bf6914d2031c
BLAKE2b-256 checksum
How to use checksums
b81d12f6366a65b76dfb199cd46c10bc65c6eee4e1332b282ba0fa395d1cf801
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / gpt_tokenizer-1.0.0-py3-none-any.whl

Download URL gpt_tokenizer-1.0.0-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b8a9a9033643a3124f37aa24ac176c7c12775ff47f374189360cb5c9d6b1847c
BLAKE2b-256 checksum
How to use checksums
7f4ea42b36dffb161b5d2bedd2f8acfdf4d41555164cdc298b590238a3bf6892
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Security for gpt-tokenizer 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page