ToonNet 1.0.4
dotnet add package ToonNet --version 1.0.4
NuGet\Install-Package ToonNet -Version 1.0.4
<PackageReference Include="ToonNet" Version="1.0.4" />
<PackageVersion Include="ToonNet" Version="1.0.4" />
<PackageReference Include="ToonNet" />
paket add ToonNet --version 1.0.4
#r "nuget: ToonNet, 1.0.4"
#:package ToonNet@1.0.4
#addin nuget:?package=ToonNet&version=1.0.4
#tool nuget:?package=ToonNet&version=1.0.4
ToonNet
ToonNet delivers a production-ready .NET implementation of TOON (Token-Oriented Object Notation), the indentation-driven format built to minimize token usage for Large Language Models while keeping telemetry and audit logs human-readable.
Purpose
TOON replaces verbose JSON punctuation with structured whitespace, explicit schema declarations, and optional length markers. The format is ideal when you need:
- Lower token counts in prompts or completions sent to LLM providers.
- Streaming-friendly logs and metrics that remain grepable.
- Deterministic payloads that can be validated even when partially read by an agent.
How the Format Works
- Indentation signals nesting - scopes advance by spaces instead of braces, so parsers only track the current depth.
- Tabular arrays - declare a row shape once (
items[2]{sku,qty}) and then emit comma, tab, or pipe separated values. - Length markers - optional
#3markers tell consumers when a block will end, preventing drift in prompt streams. - Key folding - single-child wrappers compact into dotted paths, but can be expanded while decoding to restore fully nested objects.
Because redundant braces and keys disappear, TOON routinely shrinks uniform payloads by 30-60 percent versus well-formatted JSON.
Installation
dotnet add package ToonNet
Quick Start
Encode
using ToonNetSerializer;
var payload = new
{
users = new[]
{
new { id = 1, name = "Alice", role = "admin" },
new { id = 2, name = "Bob", role = "user" }
}
};
string toon = ToonNet.Encode(payload);
/*
users[2]{id,name,role}:
1,Alice,admin
2,Bob,user
*/
Decode
using ToonNetSerializer;
const string toon = """
users[2]{id,name,role}:
1,Alice,admin
2,Bob,user
""";
var dynamicPayload = ToonNet.Decode(toon);
var typedPayload = ToonNet.Decode<UserList>(toon);
Log Example
level: info
ts: 2024-05-01T10:00:00Z
service: checkout
items[2]{sku,qty}:
SKU-1,2
SKU-2,1
The same event encoded as JSON would include repeated keys, quotes, and braces, adding roughly 60 extra characters per entry and inflating LLM token counts.
DataTable Round-Trip
using System.Data;
using ToonNetSerializer;
var table = new DataTable("Users");
table.Columns.Add("Id", typeof(int));
table.Columns.Add("Email", typeof(string));
table.Columns.Add("Active", typeof(bool));
table.Rows.Add(1, "a@example.com", true);
table.Rows.Add(2, "b@example.com", false);
var toon = ToonNet.Encode(table);
/*
tableName: "Users"
columns[3]{name,type,allowNull,unique,isPrimaryKey}:
Id,System.Int32,true,false,false
Email,System.String,true,false,false
Active,System.Boolean,true,false,false
rows[2]{Id,Email,Active}:
1,a@example.com,true
2,b@example.com,false
*/
var roundTripped = ToonNet.Decode<DataTable>(toon);
Console.WriteLine(roundTripped!.Rows.Count); // 2
Console.WriteLine(roundTripped.Rows[0]["Email"]); // a@example.com
Configuration Surface
var encodeOptions = new ToonOptions
{
Indent = 1,
Delimiter = ToonDelimiter.Tab,
UseLengthMarker = true,
KeyFolding = KeyFoldingMode.Safe,
FlattenDepth = int.MaxValue
};
var decodeOptions = new ToonDecodeOptions
{
Indent = 1,
Strict = true,
ExpandPaths = PathExpansionMode.Safe
};
Use the same option set on both sides when you need lossless round-trips across services.
Feature Highlights
- Token-aware serialization - reduces punctuation and repeated field names to stay within LLM context windows.
- Deterministic and streamable - indentation plus optional
#lengthmarkers keep agents from drifting when consuming partial data. - Human-first logging - can be tailed like plain text yet parsed like structured data.
- Dependency-free - the package only relies on the .NET base class library.
Compatibility
- .NET 10
- .NET 9
- .NET 8
- .NET 7
- .NET 6
- .NET Standard 2.0 (covers .NET Framework 4.6.1+, .NET Core 2.0+, Mono, Unity)
License
MIT License. See LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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 is compatible. 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 is compatible. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- System.Text.Json (>= 8.0.5)
-
net10.0
- No dependencies.
-
net6.0
- System.Text.Json (>= 8.0.5)
-
net7.0
- System.Text.Json (>= 8.0.5)
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (3)
Showing the top 3 NuGet packages that depend on ToonNet:
| Package | Downloads |
|---|---|
|
PRTelegramBot
An open-source framework with flexible and simple functionality for creating Telegram bots |
|
|
ThunderPropagator.BuildingBlocks
ThunderPropagator (Project ARC): High-performance data propagation; effortless, blazingly fast and cloud-native for maximum impact |
|
|
AsyncGuard
AsyncGuard adds safe fire-and-forget semantics (logging, retry, timeout, telemetry, policy, plugins) to .NET background tasks. |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on ToonNet:
| Repository | Stars |
|---|---|
|
rwjdk/MicrosoftAgentFrameworkSamples
Samples demonstrating the Microsoft Agent Framework in C#
|