Transform JSON across multiple formats and analyze token usage
π Live Demo: tokenstudio-web.vercel.app
- π Multi-Format Conversion: Convert JSON to Pretty JSON, Minified JSON, YAML, TOON, and TOML
- π― Token Analysis: Real-time token counting using OpenAI's
cl100k_basetokenizer - π 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
π Live Demo: tokenstudio-web.vercel.app
- Node.js 18+
- pnpm (or npm/yarn)
# Clone the repository
git clone https://github.com/yourusername/tokenstudio.git
cd tokenstudio
# Install dependencies
pnpm install
# Start development server
pnpm devOpen http://localhost:3000 in your browser.
# Build the application
pnpm build
# Start production server
pnpm start- Input JSON: Paste or type your JSON in the input field on the left
- 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
- 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
- Analyze: Compare token usage across different formats to find the most efficient encoding
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
When enabled, removes unnecessary quotes from simple strings (e.g., "hello" β hello) to reduce token count while maintaining valid syntax.
Color-coded token highlighting helps you understand how your data is tokenized. Each unique token gets a distinct color based on its ID.
Compare the same data across five different formats to find the most token-efficient encoding for your use case.
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)
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.
Contributions are welcome! Please feel free to submit a Pull Request.
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!