CSV to TOON Converter
Convert CSV data to TOON format with explicit structure for LLMs
CSV Input
Paste your CSV data here
TOON Output
Converted TOON output
Use in Your Code
Integrate this conversion into your application with our NPM package
1. Install the package
npm install @toonparse/core
2. Use in your code
import { toToon } from '@toonparse/core';
import Papa from 'papaparse';
// Parse CSV to array
const csvString = `id,name,role
1,Alice,admin
2,Bob,user`;
const { data } = Papa.parse(csvString, { header: true });
// Convert to TOON
const toon = toToon(data);
console.log(toon);
// [2]{id,name,role}:
// 1,Alice,admin
// 2,Bob,user💡 The @toonparse/core package includes token counting, format comparison, and eligibility checking utilities.
CSV vs TOON: What's the Difference?
CSV is the most compact format for flat tabular data, but TOON adds minimal overhead (~5-10%) to provide structure that improves LLM reliability:
- Array length declarations - LLMs know how many rows to expect
- Field headers in structure - Explicit column names
- Delimiter scoping - No confusion with commas in values
- Better validation - Structure can be verified before parsing
Format Comparison
CSV (Ultra Compact)
id,name,role 1,Alice,admin 2,Bob,user 3,Charlie,user
~15 tokens
TOON (Structured)
[3]{id,name,role}:
1,Alice,admin
2,Bob,user
3,Charlie,user~17 tokens (+13%, but with validation)
When to Use TOON Over CSV
Use TOON when:
- LLM accuracy is critical (TOON has better structure)
- You need to mix tabular and nested data
- Validation and error checking is important
- You're working with multiple related arrays
Use CSV when:
- Pure tabular data with no nesting
- Every token counts and you have simple data
- Compatibility with spreadsheet tools