JSON to TOON - VS Code Extension
Convert your JSON files to TOON (Token-Oriented Object Notation) format - an AI-optimized, token-efficient data format that reduces token usage by 30-60% compared to JSON.
What is TOON?
TOON is a modern, compact data format designed for the AI era. It preserves data structure while dramatically reducing token count, making it ideal for:
- Large Language Model (LLM) applications
- AI-powered workflows
- Token-cost optimization
- Data compression for AI contexts
Learn more: TOON vs JSON: A Modern Data Format Showdown
Features
✨ Easy Conversion
- One-click conversion from JSON to TOON format
- Access via Command Palette or right-click context menu
- Automatic output file naming (same name,
.toon extension)
✨ Smart Formatting
- Nested objects with proper indentation hierarchy
- Uniform arrays converted to compact tabular format
- Mixed-type arrays handled intelligently
- Deep nesting supported with proper structure preservation
✨ User Experience
- Progress notifications during conversion
- Success confirmations with output filename
- Detailed error messages for troubleshooting
- Converted file automatically opens in editor
✨ Production Ready
- Comprehensive error handling
- JSON validation
- Tested with 14+ unit tests
- Built on modern TypeScript & esbuild
How to Use
Method 1: Command Palette (Recommended)
- Open your JSON file in VS Code
- Press
Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (macOS)
- Type
Convert JSON to TOON
- Press Enter
- Open your JSON file in VS Code
- Right-click on the file in Explorer or Editor
- Select Convert JSON to TOON
What Happens Next
- Extension validates your JSON
- Shows progress notification
- Converts to TOON format
- Saves as
filename.toon in the same directory
- Automatically opens the new file in editor
- Shows success message
Conversion Examples
Example 1: Simple Object
Input (JSON):
{
"name": "Alice",
"age": 30,
"active": true
}
Output (TOON):
name: Alice
age: 30
active: true
Example 2: Nested Objects
Input (JSON):
{
"user": {
"id": 1,
"profile": {
"age": 30,
"city": "Bengaluru"
}
}
}
Output (TOON):
user:
id: 1
profile:
age: 30
city: Bengaluru
Input (JSON):
{
"users": [
{"id": 1, "name": "Alice", "role": "admin"},
{"id": 2, "name": "Bob", "role": "user"}
]
}
Output (TOON):
users:
[2]{id,name,role}:1,Alice,admin
2,Bob,user
Example 4: Mixed-Type Array
Input (JSON):
{
"items": [1, "text", {"key": "value"}]
}
Output (TOON):
items: 1, text, key: value
Example 5: Complex Nested Structure
Input (JSON):
{
"company": "TechCorp",
"departments": [
{
"id": 1,
"name": "Engineering",
"members": [
{"id": 1, "name": "Alice"},
{"id": 2, "name": "Bob"}
]
}
]
}
Output (TOON):
company: TechCorp
departments:
[1]{id,name,members}:1,Engineering,1|Alice|2|Bob
Supported JSON Types
| Type |
Handling |
| Objects |
Indentation-based hierarchy |
| Arrays (uniform) |
Tabular format with headers |
| Arrays (mixed) |
Comma-separated with type preservation |
| Strings |
Quoted only if containing special chars |
| Numbers |
Preserved as-is |
| Booleans |
true / false |
| Null |
null |
| Nested structures |
Full support with proper formatting |
Requirements
- VS Code 1.107.0 or higher
- No additional dependencies required
Known Limitations
- Extension only processes valid JSON files
- Output format follows TOON specification (may not be perfect for all use cases)
- For files with special character handling, review the converted output
Troubleshooting
"Please select a .json file"
- Make sure you're opening a file with
.json extension
- Try reopening the file if recently created
"Conversion failed: ..."
- Check that your JSON is valid (use VS Code's JSON formatter)
- Ensure file has proper JSON syntax
- Look at the error message for specific details
File not found or permission denied
- Ensure you have write permissions in the directory
- Check that the file path doesn't contain invalid characters
The converter processes files extremely fast:
- Small files (< 100KB): < 100ms
- Medium files (100KB - 1MB): < 500ms
- Large files (> 1MB): < 2 seconds
Release Notes
1.0.0
Initial release of JSON to TOON converter extension.
Features:
- Convert JSON files to TOON format via command palette
- Right-click context menu on JSON files
- Progress notifications and error handling
- Automatic file output with same base name
- Comprehensive format support for all JSON types
Feedback & Support
Found a bug? Have a feature request? Please open an issue on the GitHub repository.
License
MIT
Happy Converting! 🎉