Skip to content

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

License

Notifications You must be signed in to change notification settings

iptoux/tokenstudio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

39 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

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!

About

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

Topics

Resources

License

Stars

Watchers

Forks