YAML to TOON Converter

Convert YAML data to TOON format for even more token savings

YAML Input
Paste your YAML 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 yaml from 'js-yaml';

// Parse YAML to object
const yamlString = `users:
  - id: 1
    name: Alice
    role: admin`;

const data = yaml.load(yamlString);

// Convert to TOON
const toon = toToon(data);
console.log(toon);
// users[1]{id,name,role}:
//   1,Alice,admin

💡 The @toonparse/core package includes token counting, format comparison, and eligibility checking utilities.

YAML vs TOON: Which is More Efficient?

YAML is already more compact than JSON, but TOON goes even further:

  • TOON uses ~26% fewer tokens than YAML on uniform arrays
  • Better LLM accuracy - 73.9% vs YAML's 69.0%
  • Explicit structure - Array lengths and field names declared upfront

Token Comparison

YAML

users:
  - id: 1
    name: Alice
    role: admin
  - id: 2
    name: Bob
    role: user

~35 tokens

TOON

users[2]{id,name,role}:
  1,Alice,admin
  2,Bob,user

~20 tokens (43% savings)

When to Convert YAML to TOON

Convert to TOON when:

  • Your YAML contains uniform arrays of objects
  • You're using it in LLM prompts
  • Token costs matter

Keep YAML when:

  • Configuration files for applications
  • Human readability is top priority
  • Non-uniform or deeply nested data