<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Raphael Stäbler</title>
    <description>The latest articles on DEV Community by Raphael Stäbler (@prodbld).</description>
    <link>https://dev.to/prodbld</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3643701%2F990cf418-bc57-4667-b596-2bd342d89db7.jpeg</url>
      <title>DEV Community: Raphael Stäbler</title>
      <link>https://dev.to/prodbld</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/prodbld"/>
    <language>en</language>
    <item>
      <title>TOON vs JSON: A Reality Check — When It Saves Tokens and When It Doesn't</title>
      <dc:creator>Raphael Stäbler</dc:creator>
      <pubDate>Wed, 03 Dec 2025 14:37:17 +0000</pubDate>
      <link>https://dev.to/prodbld/toon-vs-json-a-reality-check-when-it-saves-tokens-and-when-it-doesnt-1b6m</link>
      <guid>https://dev.to/prodbld/toon-vs-json-a-reality-check-when-it-saves-tokens-and-when-it-doesnt-1b6m</guid>
      <description>&lt;p&gt;There's been a wave of articles lately about TOON (Token-Oriented Object Notation), many proclaiming it saves "50% tokens" or calling JSON "outdated" for LLM applications. I've spent some time analyzing the actual numbers.&lt;/p&gt;

&lt;p&gt;The verdict? &lt;strong&gt;TOON is genuinely useful—but the marketing oversimplifies reality.&lt;/strong&gt; Let me set the record straight so you can make informed decisions about when to use it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 50% Savings Claim: A Misleading Baseline
&lt;/h2&gt;

&lt;p&gt;Here's the uncomfortable truth that many TOON articles gloss over: the "50% savings" figure is typically measured against &lt;strong&gt;formatted JSON&lt;/strong&gt; (with pretty-printing, indentation, and whitespace). But real-world API calls and LLM prompts use &lt;strong&gt;minified JSON&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;When you compare against minified JSON - which is what you're actually sending to your LLM—the picture changes dramatically:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Data Type&lt;/th&gt;
&lt;th&gt;vs Minified JSON&lt;/th&gt;
&lt;th&gt;Reality&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Uniform arrays (user lists, logs)&lt;/td&gt;
&lt;td&gt;20-35% savings&lt;/td&gt;
&lt;td&gt;This is where TOON shines&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;API responses with arrays&lt;/td&gt;
&lt;td&gt;0-15% savings&lt;/td&gt;
&lt;td&gt;Modest improvement&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mixed nested structures&lt;/td&gt;
&lt;td&gt;-5% to +10%&lt;/td&gt;
&lt;td&gt;Results vary, test your data&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Configuration objects&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;+10% to +20% MORE tokens&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;TOON hurts here&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Deeply nested objects&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;+15% to +20% MORE tokens&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;TOON hurts here&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Single flat objects&lt;/td&gt;
&lt;td&gt;-5% to +5%&lt;/td&gt;
&lt;td&gt;Negligible difference&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Yes, you read that correctly: TOON can &lt;em&gt;increase&lt;/em&gt; your token usage by 15-20% depending on your data structure.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How TOON Works (and Why Structure Matters)
&lt;/h2&gt;

&lt;p&gt;TOON saves tokens through a clever trick: for uniform arrays, it declares field names once in a header, then streams values in CSV-like rows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;users[3]{id,name,role}:
1,Alice,admin
2,Bob,user
3,Carol,user
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Compared to the equivalent minified JSON:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"users"&lt;/span&gt;&lt;span class="p"&gt;:[{&lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"Alice"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"admin"&lt;/span&gt;&lt;span class="p"&gt;},{&lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"Bob"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"user"&lt;/span&gt;&lt;span class="p"&gt;},{&lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"Carol"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"user"&lt;/span&gt;&lt;span class="p"&gt;}]}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The savings come from not repeating &lt;code&gt;"id":&lt;/code&gt;, &lt;code&gt;"name":&lt;/code&gt;, and &lt;code&gt;"role":&lt;/code&gt; for every record. With 100 records, this adds up significantly.&lt;/p&gt;

&lt;p&gt;But here's the catch: &lt;strong&gt;TOON still needs syntax for non-tabular data.&lt;/strong&gt; For nested objects, it uses YAML-style indentation, which can actually be &lt;em&gt;more&lt;/em&gt; verbose than minified JSON because:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Whitespace (indentation) consumes tokens&lt;/li&gt;
&lt;li&gt;YAML-style key declarations still repeat&lt;/li&gt;
&lt;li&gt;The format overhead for small objects exceeds JSON's braces&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  When TOON Actually Hurts You
&lt;/h2&gt;

&lt;p&gt;Let me show you a real example. Consider this configuration object:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"debug"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"maxRetries"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"timeout"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"features"&lt;/span&gt;&lt;span class="p"&gt;:{&lt;/span&gt;&lt;span class="nl"&gt;"darkMode"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"beta"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;}}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In TOON, this becomes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;debug: true
maxRetries: 3
timeout: 5000
features:
  darkMode: true
  beta: false
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The minified JSON is &lt;strong&gt;actually more token-efficient&lt;/strong&gt; because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No newlines between properties&lt;/li&gt;
&lt;li&gt;No indentation overhead&lt;/li&gt;
&lt;li&gt;Colons and braces are single tokens anyway&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;My benchmarks at &lt;a href="https://www.json2toon.de" rel="noopener noreferrer"&gt;json2toon.de&lt;/a&gt; consistently show configuration objects using 10-20% &lt;em&gt;more&lt;/em&gt; tokens in TOON format.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Complete Decision Matrix
&lt;/h2&gt;

&lt;p&gt;Based on extensive testing, here's when to use each format:&lt;/p&gt;

&lt;h3&gt;
  
  
  Use TOON when:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;You have &lt;strong&gt;large arrays of uniform objects&lt;/strong&gt; (100+ records with consistent fields)&lt;/li&gt;
&lt;li&gt;Your data is primarily &lt;strong&gt;tabular&lt;/strong&gt; (user lists, product catalogs, log entries, analytics data)&lt;/li&gt;
&lt;li&gt;Every object in your array has the &lt;strong&gt;same fields&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;You're processing &lt;strong&gt;paginated API results&lt;/strong&gt; with uniform structure&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Stick with minified JSON when:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Your data has &lt;strong&gt;deep nesting&lt;/strong&gt; (org charts, recursive trees)&lt;/li&gt;
&lt;li&gt;You're sending &lt;strong&gt;configuration objects&lt;/strong&gt; or feature flags&lt;/li&gt;
&lt;li&gt;Your objects have &lt;strong&gt;varying fields&lt;/strong&gt; (sparse data)&lt;/li&gt;
&lt;li&gt;You have &lt;strong&gt;mixed structures&lt;/strong&gt; (some arrays, some nested objects)&lt;/li&gt;
&lt;li&gt;You're dealing with &lt;strong&gt;single flat objects&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Consider plain CSV when:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Your data is &lt;strong&gt;purely tabular&lt;/strong&gt; with no hierarchy&lt;/li&gt;
&lt;li&gt;You don't need nested structures at all&lt;/li&gt;
&lt;li&gt;You want maximum token efficiency (CSV beats TOON by ~30% for flat tables)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What about YAML?
&lt;/h3&gt;

&lt;p&gt;Despite some suggestions, YAML is typically the &lt;em&gt;worst&lt;/em&gt; choice for token efficiency. It uses approximately 21% &lt;em&gt;more&lt;/em&gt; tokens than minified JSON because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Whitespace carries meaning and can't be removed&lt;/li&gt;
&lt;li&gt;Keys still repeat for every array item&lt;/li&gt;
&lt;li&gt;No tabular optimization like TOON provides&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Hidden Gotchas
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. LLM Training Data Bias
&lt;/h3&gt;

&lt;p&gt;Most LLMs were trained predominantly on JSON. When you use TOON, you may need to include format explanations in your prompts, which partially negates your token savings. Some developers report that smaller models (like GPT-3.5-Turbo) struggle to &lt;em&gt;output&lt;/em&gt; valid TOON even when they understand TOON &lt;em&gt;input&lt;/em&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. No Standard Specification (Yet)
&lt;/h3&gt;

&lt;p&gt;While there's an open spec on GitHub, TOON lacks the RFC-level standardization of JSON. There's no guarantee of consistent parsing across implementations.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Debugging Complexity
&lt;/h3&gt;

&lt;p&gt;When something goes wrong in your LLM pipeline, debugging TOON is harder than debugging JSON. Most tools, loggers, and validators expect JSON.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Mixed Data Penalty
&lt;/h3&gt;

&lt;p&gt;Real-world API responses often mix arrays with metadata. If your response looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"total"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;150&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"page"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"users"&lt;/span&gt;&lt;span class="p"&gt;:[&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Only the &lt;code&gt;users&lt;/code&gt; array benefits from TOON optimization. The metadata overhead remains, and TOON's format declarations for small objects may actually increase total tokens.&lt;/p&gt;

&lt;h2&gt;
  
  
  My Recommendation: Measure, Don't Assume
&lt;/h2&gt;

&lt;p&gt;Don't blindly convert all your JSON to TOON based on marketing claims. Instead:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Use real data&lt;/strong&gt;: Test with your actual payloads, not synthetic examples&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Compare against minified JSON&lt;/strong&gt;: Use the "Minify" button in converters to see accurate savings&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Profile your specific structure&lt;/strong&gt;: Uniform arrays will save tokens; config objects won't&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Consider the full picture&lt;/strong&gt;: Include any format explanation prompts in your token calculation&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Test LLM comprehension&lt;/strong&gt;: Make sure your target model actually understands TOON output&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can try this yourself at &lt;a href="https://www.json2toon.de" rel="noopener noreferrer"&gt;json2toon.de&lt;/a&gt; — paste your real production data and see the &lt;em&gt;actual&lt;/em&gt; savings (or costs) for your specific use case.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion: It's Not JSON vs TOON - It's Using the Right Tool
&lt;/h2&gt;

&lt;p&gt;TOON is a valuable addition to the developer toolkit. For uniform arrays of objects, it delivers genuine 20-35% token savings against minified JSON. That's real money at scale.&lt;/p&gt;

&lt;p&gt;But it's not a universal JSON replacement. The "JSON is costing you money" narrative ignores that &lt;strong&gt;TOON costs you money too&lt;/strong&gt; - sometimes &lt;em&gt;more&lt;/em&gt; money - when applied to the wrong data structures.&lt;/p&gt;

&lt;p&gt;The future isn't "TOON everywhere." It's intelligent format selection based on your actual data:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Uniform arrays&lt;/strong&gt; → TOON&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Flat tabular data&lt;/strong&gt; → CSV
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Everything else&lt;/strong&gt; → Minified JSON&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Don't let hype drive your architecture decisions. Measure your specific use case, understand the tradeoffs, and choose accordingly.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Built &lt;a href="https://www.json2toon.de" rel="noopener noreferrer"&gt;json2toon.de&lt;/a&gt; to help developers make data-driven format decisions. Try it with your real payloads and see the actual numbers.&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;What's your experience been?&lt;/strong&gt; Have you seen the promised savings, or did you run into the scenarios where TOON increased your token usage? Share your benchmarks in the comments—I'd love to see real-world data from the community.&lt;/p&gt;

</description>
      <category>data</category>
      <category>llm</category>
      <category>ai</category>
      <category>performance</category>
    </item>
  </channel>
</rss>
