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
<PackageReference Include="Nizzola.ToonConvert.NET" Version="1.0.0" />
<PackageVersion Include="Nizzola.ToonConvert.NET" Version="1.0.0" />
<PackageReference Include="Nizzola.ToonConvert.NET" />
paket add Nizzola.ToonConvert.NET --version 1.0.0
#r "nuget: Nizzola.ToonConvert.NET, 1.0.0"
#:package Nizzola.ToonConvert.NET@1.0.0
#addin nuget:?package=Nizzola.ToonConvert.NET&version=1.0.0
#tool nuget:?package=Nizzola.ToonConvert.NET&version=1.0.0
NIZZOLA.TOON.NET
Token-Oriented Object Notation (TOON) serializer for .NET
๐ 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
StringBuilderand 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 = 2to balance readability and compactness. - Enable tabular detection when serializing large homogeneous lists to maximize token savings.
- Align
NamingPolicywith 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
Case 2 - with mixed data types
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
StringBuilderand 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/Deserializeoverloads. - ๐ 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:
Your support helps maintain and improve this open-source project.
Follow me
| Product | Versions 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. |
-
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 |