Nizzola.ToonConvert.NET 1.0.0

dotnet add package Nizzola.ToonConvert.NET --version 1.0.0
                    
NuGet\Install-Package Nizzola.ToonConvert.NET -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Nizzola.ToonConvert.NET" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Nizzola.ToonConvert.NET" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Nizzola.ToonConvert.NET" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Nizzola.ToonConvert.NET --version 1.0.0
                    
#r "nuget: Nizzola.ToonConvert.NET, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Nizzola.ToonConvert.NET@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Nizzola.ToonConvert.NET&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Nizzola.ToonConvert.NET&version=1.0.0
                    
Install as a Cake Tool

NIZZOLA.TOON.NET

Token-Oriented Object Notation (TOON) serializer for .NET

NuGet License: MIT

๐Ÿš€ Overview

NIZZOLA.TOON.NET is a high-performance serialization library created for AI and LLM workloads. By using a compact, token-oriented format (TOON) it can reduce token usage by roughly 30โ€“60% compared to JSON. This yields:

  • โšก Lower API costs when calling LLMs
  • ๐Ÿƒ Faster end-to-end response times
  • ๐Ÿ“Š Better throughput for flat or tabular data
  • ๐Ÿ‘๏ธ Human-readable output for debugging and prompts

๐Ÿ“ฆ Installation

dotnet add package Nizzola.TOON.NET

Documentation

This README contains a concise implementation overview and quick reference. See the source code in src/NizzolaToon/ for API details and examples.

Implementation (summary)

  • ๐Ÿ”ง ToonSerializer โ€” Main static API for Serialize/Deserialize (familiar API surface like JsonSerializer).
  • โœ๏ธ ToonWriter โ€” Formatting engine that writes TOON with optimized indentation and stream support.
  • โš™๏ธ ToonSerializerOptions โ€” Configuration (naming policies, indentation, tabular detection, async support).
  • ๐Ÿšซ ToonIgnoreAttribute โ€” Attribute to exclude properties from serialization.

Quick feature overview

  • ๐Ÿงพ Automatic tabularization: detects homogeneous lists and emits a header + rows representation.
  • ๐Ÿ” Token reduction: minimizes braces/quotes/commas and uses indentation and CSV-like compacting for simple arrays.
  • โšก Performance: built on StringBuilder and optimized reflection paths.
  • ๐Ÿ”Œ Extensible: attributes and naming policies (CamelCase / snake_case) let you adapt the output to your LLM prompts.

Example usage

// Serialize
var toon = ToonSerializer.Serialize(obj, new ToonSerializerOptions { Indentation = 2, NamingPolicy = NamingPolicy.CamelCase });

// Deserialize
var model = ToonSerializer.Deserialize<MyModel>(toon);

// Streams / async
await ToonSerializer.SerializeAsync(stream, obj, options);
var result = await ToonSerializer.DeserializeAsync<MyModel>(stream);

Quick tips

  • Use Indentation = 2 to balance readability and compactness.
  • Enable tabular detection when serializing large homogeneous lists to maximize token savings.
  • Align NamingPolicy with the conventions your LLM expects (camelCase, snake_case, etc.).

Short reference

Symbol Item Purpose
๐Ÿ”ง ToonSerializer Main API (sync/async serialization)
โœ๏ธ ToonWriter Formatting engine and output writer
โš™๏ธ ToonSerializerOptions Behavioral options and naming policies
๐Ÿšซ ToonIgnoreAttribute Exclude properties from serialization

Before and after comparison

Case 1 - with single data type TOON vs JSON sample 1

Case 2 - with mixed data types TOON vs JSON sample 2

The more rows an entity has, the greater the token savings with this model.

Key features

  • Tabular data detection: automatically detects lists of objects with identical shape and serializes them as a table (header + rows).
  • Token reduction strategies: removes unnecessary braces/quotes/commas, relies on indentation and compact CSV-like arrays for simple sequences.
  • Flexible: serializes CLR objects, can convert existing JSON to TOON, and supports streaming/async scenarios.
  • Naming policies: compatible with System.Text.Json-style policies (camelCase, snake_case).
  • Performance: optimized for throughput using StringBuilder and targeted reflection caching.

โœจ Benefits

  • ๐ŸŽฏ Reduce token consumption by ~30โ€“60% compared to JSON when used with LLMs.
  • ๐Ÿ‘จโ€๐Ÿ’ป Familiar API for .NET developers, easing adoption.
  • ๐Ÿ”’ Type-safe usage via generic Serialize / Deserialize overloads.
  • ๐Ÿ”Œ Extensible via attributes and options for customization.

This library is prepared for NuGet publication and production use with LLM-powered workflows.

โ˜• Support the project

If you find this library useful and want to support development, consider buying me a coffee:

Buy me a coffee!

Your support helps maintain and improve this open-source project.

Follow me

LinkedIn Medium Instagram Linktree

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 3,018 11/11/2025