| Crates.io | toonconv |
| lib.rs | toonconv |
| version | 0.1.0 |
| created_at | 2025-11-24 12:34:51.551047+00 |
| updated_at | 2025-11-24 12:34:51.551047+00 |
| description | A Rust CLI tool for converting JSON to TOON (Token-Oriented Object Notation) format |
| homepage | |
| repository | https://github.com/lst97/toonconv |
| max_upload_size | |
| id | 1947716 |
| size | 551,401 |
toonconv is a blazingly fast, high-performance Rust CLI tool for converting JSON data into TOON (Token-Oriented Object Notation) format. It's designed for LLM applications, data processing pipelines, and scenarios where token efficiency matters.
| Implementation | CLI Execution Time | Token Efficiency |
|---|---|---|
| toonconv (Rust) | ~5ms | 35-54% reduction |
| @toon-format/cli (JS) | ~959ms | Baseline |
Benchmarks run on Apple M1 Mac Air. See BENCHMARK.md for detailed analysis.
# Clone the repository
git clone https://github.com/lst97/toonconv.git
cd toonconv
# Build release version
cargo build --release
# Install globally (optional)
cargo install --path .
# Direct JSON string (NEW!)
toonconv '{"name": "Alice", "age": 30}'
# From file
toonconv input.json -o output.toon
# From stdin
echo '{"status": "ok"}' | toonconv --stdin
# Batch directory conversion
toonconv input_dir/ -o output_dir/
# Input JSON
{"users": [{"id": 1, "name": "Alice"}, {"id": 2, "name": "Bob"}]}
# Output TOON
users[2]{id,name}: 1,Alice 2,Bob
toonconv supports 4 different ways to convert JSON to TOON:
Perfect for quick conversions and testing.
# Convert a JSON object
toonconv '{"name": "Alice", "age": 30}'
# Convert a JSON array
toonconv '[1, 2, 3, 4, 5]'
# Nested structures
toonconv '{"user": {"name": "Bob", "email": "bob@example.com"}}'
Great for Unix pipelines and data workflows.
# From echo
echo '{"status": "ok"}' | toonconv --stdin
# From API response
curl -s https://api.example.com/data | toonconv --stdin
# Chain with jq
jq '.results[]' data.json | toonconv --stdin
Convert individual files with custom output paths.
# Basic conversion
toonconv input.json
# Custom output
toonconv input.json -o custom_output.toon
# Pretty formatting
toonconv input.json --format pretty
Process entire directories while preserving structure.
# Recursive conversion (default)
toonconv input_dir/ -o output_dir/
# Non-recursive
toonconv input_dir/ -o output_dir/ --no-recursive
# Continue on errors
toonconv input_dir/ -o output_dir/ --continue-on-error
# Pretty-print output (default)
toonconv data.json --format pretty
# Compact output
toonconv data.json --format compact
# Minified output
toonconv data.json --format minified
# Set memory limit (default: 512MB)
toonconv large.json --memory-limit 1073741824 # 1GB
# For very large files
toonconv huge.json --memory-limit 2147483648 # 2GB
# Quiet mode (errors only)
toonconv data.json --quiet
# Verbose mode (detailed progress)
toonconv data.json --verbose
# Debug mode (maximum detail)
toonconv data.json --debug
toonconv/
โโโ src/
โ โโโ cli/ # CLI argument parsing and commands
โ โโโ conversion/ # Core conversion engine
โ โโโ formatter/ # TOON format output generation
โ โโโ parser/ # JSON parsing with validation
โ โโโ validation/ # Input validation and error handling
โ โโโ error/ # Custom error types
โ โโโ lib.rs # Library entry point
โ โโโ main.rs # Binary entry point
โโโ tests/ # Comprehensive test suite
โโโ benches/ # Performance benchmarks
โโโ examples/ # Usage examples
โโโ specs/ # TOON format specifications
serde, serde_jsonclap with derive macrossimd-json supportindicatif, consolewalkdir for recursive traversalRun the comprehensive test suite:
# All tests
cargo test
# TOON specification compliance
cargo test --test toon_spec_compliance_test
# Performance benchmarks
cargo bench
# Code quality
cargo clippy
cargo fmt
Compare performance with the official JavaScript implementation:
# Run built-in benchmarks
cargo bench --bench token_efficiency
cargo bench --bench speed_comparison
# Compare with JavaScript version
node bench/speed.js
See BENCHMARK.md for detailed performance analysis.
# Development build
cargo build
# Release build (optimized)
cargo build --release
# Check code quality
cargo clippy
cargo fmt --check
git checkout -b feature-namecargo testSee AGENTS.md for development guidelines.
# Fetch, filter, convert
curl -s https://api.example.com/users | \
jq '.data.users' | \
toonconv --stdin -o users.toon
# Convert all JSON files, skip errors
find . -name "*.json" -type f | while read file; do
toonconv "$file" -o "${file%.json}.toon" --continue-on-error
done
#!/bin/bash
# .git/hooks/pre-commit
for file in config/*.json; do
toonconv "$file" -o "${file%.json}.toon"
git add "${file%.json}.toon"
done
# Clean build
cargo clean
cargo update
cargo build --release
--memory-limit flagThis project is licensed under the MIT License - see the LICENSE file for details.
Website โข Documentation โข Issues โข Discussions
Made with โค๏ธ using Rust