An interactive web application that demonstrates how AI models convert text into tokens. Features a stunning warm amber dark theme with comprehensive tokenization visualization and real-time text analysis.
- Convert any text into numerical tokens with step-by-step visualization
- Real-time encoding sequence display with detailed process explanation
- Predefined vocabulary lookup with ASCII fallback for unknown characters
- Interactive token grid display with hover effects and statistics
- Convert token arrays back to readable text with detailed decoding steps
- Support for vocabulary tokens and ASCII-encoded characters
- Error handling for invalid or out-of-range tokens
- Visual representation of the decoding process
- Browse the complete predefined vocabulary with search functionality
- Real-time filtering as you type
- Toggle ASCII character range display (32-126)
- Character-to-token mapping visualization with type indicators
- Interactive token grid with visual representation
- Real-time statistics including:
- Character count
- Token count
- Compression ratio calculation
- Visual token representation with hover tooltips
- One-click copy functionality for all sections
- Visual feedback with toast notifications
- Support for encoding results, decoding results, and vocabulary entries
- Warm Amber Dark Theme: Modern, professional design with amber accents
- Responsive Design: Works perfectly on desktop, tablet, and mobile devices
- Tab Navigation: Clean separation between encoding and decoding sections
- Modern UI: Clean, professional interface with intuitive navigation
- Modern web browser (Chrome, Firefox, Safari, Edge)
- No additional dependencies required!
- Clone or download the repository
- Open
index.htmlin your web browser - Start exploring tokenization!
# Clone the repository
git clone <repository-url>
cd tokenvisualizer
# Open in browser
open index.htmltokenvisualizer/
├── index.html # Main HTML structure with tab navigation
├── styles.css # Warm amber dark theme styling
├── tokenizer.js # Core tokenization logic and vocabulary
├── ui.js # User interface management and DOM updates
├── app.js # Main application controller and utilities
└── README.md # Project documentation
- Text Input: User enters text in the encoding section
- Word Splitting: Text is split into words and punctuation
- Vocabulary Lookup: Each word is checked against the predefined vocabulary
- ASCII Fallback: Unknown characters are encoded using ASCII values + 2000 offset
- Token Generation: Final array of numerical tokens is produced
- Special Tokens (0-99):
<PAD>,<UNK>,<START>,<END>,<MASK>, etc. - Common Words (100-999): Frequently used English words
- Punctuation (1000-1099): Symbols and punctuation marks
- ASCII Range (2000+): ASCII characters with offset for unknown text
Input: "Hello world"
Tokens: [2000, 2001, 2002, 2002, 2003, 2004, 2005, 2006, 2007, 2002, 2008]
Input: 72, 101, 108, 108, 111
Output: "Hello"
- Modular Design: Separated concerns with dedicated modules
- Event-Driven: Responsive UI with real-time updates
- Class-Based: Object-oriented JavaScript with ES6 classes
- Error Handling: Comprehensive error management and user feedback
- Chrome 60+
- Firefox 55+
- Safari 12+
- Edge 79+
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
If you encounter any issues or have questions, please open an issue on the repository.
Made with ❤️ by Mohit Kumar