Skip to content
| Marketplace
Sign in
Visual Studio Code>Formatters>JSON to TOONNew to Visual Studio Code? Get it now.
JSON to TOON

JSON to TOON

Patryk Penczek

|
5 installs
| (1) | Free
Convert JSON files to TOON format with token savings visualization. See exactly how much you save on LLM API costs.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

JSON to TOON Converter

Convert JSON files to TOON format and reduce your LLM API token usage. See exactly how many tokens you save with each conversion.

🎯 What is TOON?

TOON is a token-optimized format for representing structured data in LLM prompts. It uses significantly fewer tokens than JSON while maintaining readability and structure, resulting in:

  • Lower API costs - Fewer tokens = less money spent on API calls
  • Larger context windows - Fit more data in the same token budget
  • Better performance - Less data for the LLM to process

✨ Features

  • Bidirectional Conversion: Convert JSON ↔ TOON seamlessly
  • Token Counting: Accurate token counting using Claude Sonnet 4.5 tokenizer
  • Savings Visualization: See exactly how many tokens and what percentage you save
  • Batch Operations: Convert or revert all files in your workspace at once
  • File Replacement: Converts files in-place (JSON → TOON or TOON → JSON)
  • Keyboard Shortcut: Quick conversion with Ctrl+Shift+T (or Cmd+Shift+T on Mac)

📦 Installation

From VS Code Marketplace

  1. Open VS Code
  2. Go to Extensions (Ctrl+Shift+X)
  3. Search for "JSON to TOON Converter"
  4. Click Install

From VSIX File

  1. Download the .vsix file from releases
  2. Open VS Code Extensions (Ctrl+Shift+X)
  3. Click "..." menu → "Install from VSIX..."
  4. Select the downloaded file

🚀 Usage

Convert Single File (JSON → TOON)

  1. Open any .json file in VS Code
  2. Right-click in the editor or file explorer
  3. Select "Convert JSON to TOON"
  4. Your file is converted to .toon and the original .json is removed

Or use keyboard shortcut: Ctrl+Shift+T (Windows/Linux) or Cmd+Shift+T (macOS)

Convert All Files (JSON → TOON)

  1. Open Command Palette (Ctrl+Shift+P or Cmd+Shift+P)
  2. Type "Convert All JSON Files to TOON"
  3. All .json files in your workspace are converted to .toon

Revert Single File (TOON → JSON)

  1. Open any .toon file in VS Code
  2. Right-click in the editor or file explorer
  3. Select "Revert TOON to JSON"
  4. Your file is converted back to .json and the .toon file is removed

Revert All Files (TOON → JSON)

  1. Open Command Palette (Ctrl+Shift+P or Cmd+Shift+P)
  2. Type "Revert All TOON Files to JSON"
  3. All .toon files in your workspace are converted back to .json

📊 Real-World Example

Let's compare a typical API response with user data:

Input JSON (487 tokens):

{
  "users": [
    {
      "id": "usr_1234567890",
      "username": "john.doe",
      "email": "john.doe@example.com",
      "role": "admin",
      "is_active": true,
      "login_count": 156
    },
    {
      "id": "usr_0987654321",
      "username": "jane.smith",
      "email": "jane.smith@example.com",
      "role": "user",
      "is_active": true,
      "login_count": 89
    },
    {
      "id": "usr_5555555555",
      "username": "bob.wilson",
      "email": "bob.wilson@example.com",
      "role": "user",
      "is_active": false,
      "login_count": 12
    }
  ],
  "pagination": {
    "current_page": 1,
    "total_pages": 10,
    "per_page": 20,
    "total_items": 200
  }
}

Output TOON (243 tokens):

users[3]{id,username,email,role,is_active,login_count}:
  usr_1234567890,john.doe,john.doe@example.com,admin,true,156
  usr_0987654321,jane.smith,jane.smith@example.com,user,true,89
  usr_5555555555,bob.wilson,bob.wilson@example.com,user,false,12
pagination:
  current_page: 1
  total_pages: 10
  per_page: 20
  total_items: 200

Result: ✨ Converted 1 file to TOON! 🎉 Total saved: 244 tokens (50.1%)

Notice how TOON's compact table syntax users[3]{id,username,email,role,is_active,login_count}: eliminates repetitive field names and brackets, saving tokens while maintaining perfect readability!

💰 Cost Impact

With Claude Sonnet 4.5 pricing ($3 per 1M input tokens):

  • 1,000 API calls: Save $0.73
  • 10,000 API calls: Save $7.32
  • 100,000 API calls: Save $73.20
  • 1M API calls: Save $732.00

The savings add up quickly, especially for high-volume applications!

🤖 Using TOON Files with LLMs

To maximize your token savings, configure your AI coding assistants to use TOON files instead of JSON:

For Claude (via .clinerules or .cursorrules)

Add this instruction to your .clinerules or .cursorrules file:

When working with structured data files in this project:
- Always use .toon files instead of .json files for reading data
- TOON format is more token-efficient than JSON
- Parse TOON files using the @toon-format/toon library

For GitHub Copilot

Add this to your workspace settings (.vscode/settings.json):

{
  "github.copilot.advanced": {
    "inlineSuggestCount": 3,
    "instructions": [
      "When reading structured data, prefer .toon files over .json files to save tokens",
      "Use @toon-format/toon library to parse TOON format files"
    ]
  }
}

General LLM Instructions

Include this in your project documentation or system prompts:

This project uses TOON format (.toon files) for structured data instead of JSON to reduce token usage.
Always read from .toon files when available. Use the decode() function from @toon-format/toon to parse them.

⚙️ Configuration

Configure the extension through VS Code settings:

{
  "jsonToToon.showStats": true // Set to false to hide token statistics
}

🔧 Requirements

  • VS Code 1.96.0 or higher
  • The extension works out of the box - no additional dependencies needed

📝 Commands

Command Description
Convert JSON to TOON Convert single JSON file to TOON format
Convert All JSON Files to TOON Convert all JSON files in workspace to TOON
Revert TOON to JSON Convert single TOON file back to JSON
Revert All TOON Files to JSON Convert all TOON files in workspace back to JSON

🐛 Troubleshooting

Extension Not Working

  • Ensure you have a .json or .toon file open
  • Check VS Code version (must be 1.96.0+)
  • Reload VS Code: Ctrl+Shift+P → "Reload Window"

Token Counting Issues

  • The extension uses js-tiktoken with Claude Sonnet 4.5 tokenizer
  • Falls back to estimation (chars/4) if tokenizer fails
  • Check Output panel: "JSON to TOON" for detailed logs

Conversion Errors

  • Verify JSON is valid using VS Code's built-in JSON validator
  • Check the Output panel for detailed error messages
  • Ensure files are not read-only

🛠️ Development

Building from Source

# Clone repository
git clone https://github.com/patryk-penczek/json-to-toon-converter.git
cd json-to-toon-converter

# Install dependencies
npm install

# Compile TypeScript
npm run compile

# Test in Extension Development Host
# Press F5 in VS Code

🤝 Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

📄 License

MIT License - see LICENSE file for details

🔗 Links

  • GitHub Repository
  • TOON Format Specification
  • Report Issues

💖 Support

If you find this extension helpful:

  • ⭐ Star the repository
  • 🐛 Report bugs and issues
  • 💡 Suggest new features
  • 📢 Share with others

Save tokens, save money! Made for the LLM community 🚀

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft