ToonNet 1.0.4

dotnet add package ToonNet --version 1.0.4
                    
NuGet\Install-Package ToonNet -Version 1.0.4
                    
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="ToonNet" Version="1.0.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ToonNet" Version="1.0.4" />
                    
Directory.Packages.props
<PackageReference Include="ToonNet" />
                    
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 ToonNet --version 1.0.4
                    
#r "nuget: ToonNet, 1.0.4"
                    
#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 ToonNet@1.0.4
                    
#: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=ToonNet&version=1.0.4
                    
Install as a Cake Addin
#tool nuget:?package=ToonNet&version=1.0.4
                    
Install as a Cake Tool

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.

NuGet License: MIT


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

  1. Indentation signals nesting - scopes advance by spaces instead of braces, so parsers only track the current depth.
  2. Tabular arrays - declare a row shape once (items[2]{sku,qty}) and then emit comma, tab, or pipe separated values.
  3. Length markers - optional #3 markers tell consumers when a block will end, preventing drift in prompt streams.
  4. 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 #length markers 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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#
Version Downloads Last Updated
1.0.4 1,999 11/20/2025
1.0.3 474 11/17/2025
1.0.2 242 11/14/2025
1.0.1 285 11/11/2025
1.0.0 285 11/11/2025