GitHunt
IP

iptoux/tokenstudio

Token Studio - Transform JSON across multiple formats and analyze token usage with real-time token counting and visualization

Token Studio Token Studio

Transform JSON across multiple formats and analyze token usage

Live Demo
JSON
YAML
TOON
TOML

๐ŸŒ Live Demo: tokenstudio-web.vercel.app


โœจ Features

  • ๐Ÿ”„ Multi-Format Conversion: Convert JSON to Pretty JSON, Minified JSON, YAML, TOON, and TOML
  • ๐ŸŽฏ Token Analysis: Real-time token counting using OpenAI's cl100k_base tokenizer
  • ๐Ÿ“Š Token Visualization: Highlight tokens with color-coded display
  • ๐Ÿง  Token-Aware Formatting: Optimize output by removing unnecessary quotes from simple strings
  • ๐Ÿ“ˆ Count Comparison: Compare character, byte, and token counts across all formats
  • ๐Ÿ“‹ Copy-Ready Outputs: One-click copy for any format
  • ๐ŸŽจ Modern UI: Beautiful, responsive interface built with Radix UI and Tailwind CSS
  • ๐ŸŒ“ Dark Mode: Built-in theme support

๐Ÿš€ Quick Start

๐ŸŒ Live Demo: tokenstudio-web.vercel.app

Prerequisites

  • Node.js 18+
  • pnpm (or npm/yarn)

Installation

# Clone the repository
git clone https://github.com/yourusername/tokenstudio.git
cd tokenstudio

# Install dependencies
pnpm install

# Start development server
pnpm dev

Open http://localhost:3000 in your browser.

Build for Production

# Build the application
pnpm build

# Start production server
pnpm start

๐Ÿ“– Usage

  1. Input JSON: Paste or type your JSON in the input field on the left
  2. Choose Format: Select from five output formats:
    • Original JSON: Pretty-printed with indentation
    • Minified JSON: Compact single-line format
    • YAML: Human-readable YAML format
    • TOON: Compact TOON encoding format
    • TOML: TOML configuration format
  3. Enable Features:
    • Token Aware: Remove quotes from simple strings to optimize token count
    • Show Tokens: Visualize tokens with color highlighting
    • Show Counts: Display character, byte, and token counts
    • Copy-Ready: Enable copy buttons for quick access
  4. Analyze: Compare token usage across different formats to find the most efficient encoding

๐Ÿ› ๏ธ Tech Stack

Category Technology
Framework Next.js Next.js 16
UI Library React React 19
Language TypeScript TypeScript 5
Styling Tailwind CSS Tailwind CSS 4
UI Components Radix UI Radix UI
Tokenization TikToken @dqbd/tiktoken
Icons Lucide Lucide React
Formats TOON, TOML, YAML

๐Ÿ“ Project Structure

tokenstudio/
โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ api/
โ”‚   โ”‚   โ””โ”€โ”€ tokenize/        # Tokenization API endpoint
โ”‚   โ”œโ”€โ”€ page.tsx             # Main application page
โ”‚   โ””โ”€โ”€ layout.tsx           # Root layout
โ”œโ”€โ”€ components/
โ”‚   โ”œโ”€โ”€ token-studio/        # Token studio components
โ”‚   โ””โ”€โ”€ ui/                  # Reusable UI components
โ”œโ”€โ”€ lib/
โ”‚   โ”œโ”€โ”€ types.ts             # TypeScript type definitions
โ”‚   โ””โ”€โ”€ utils/               # Utility functions
โ”‚       โ”œโ”€โ”€ json.ts          # JSON/YAML conversion
โ”‚       โ”œโ”€โ”€ toml.ts          # TOML conversion
โ”‚       โ”œโ”€โ”€ toon.ts          # TOON encoding
โ”‚       โ””โ”€โ”€ tokenization.ts  # Token utilities
โ””โ”€โ”€ hooks/
    โ””โ”€โ”€ use-tokenization.ts  # Tokenization hook

๐ŸŽฏ Key Features Explained

Token-Aware Formatting

When enabled, removes unnecessary quotes from simple strings (e.g., "hello" โ†’ hello) to reduce token count while maintaining valid syntax.

Token Visualization

Color-coded token highlighting helps you understand how your data is tokenized. Each unique token gets a distinct color based on its ID.

Format Comparison

Compare the same data across five different formats to find the most token-efficient encoding for your use case.

๐Ÿ› Reporting Issues

Found a bug or have a feature request? Please open an issue on GitHub:

๐Ÿ”— Create an Issue

When reporting bugs, please include:

  • Steps to reproduce
  • Expected behavior
  • Actual behavior
  • Browser and OS information
  • Screenshots (if applicable)

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

MIT License - You are free to use, modify, and distribute this software for any purpose, including commercial use.

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

๐Ÿ“„ License Summary

MIT License

Copyright (c) 2024 Token Studio

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Made with โค๏ธ using Next.js and React

โญ Star this repo if you find it useful!