Toon.DotNet 1.5.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Toon.DotNet --version 1.5.2
                    
NuGet\Install-Package Toon.DotNet -Version 1.5.2
                    
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="Toon.DotNet" Version="1.5.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Toon.DotNet" Version="1.5.2" />
                    
Directory.Packages.props
<PackageReference Include="Toon.DotNet" />
                    
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 Toon.DotNet --version 1.5.2
                    
#r "nuget: Toon.DotNet, 1.5.2"
                    
#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 Toon.DotNet@1.5.2
                    
#: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=Toon.DotNet&version=1.5.2
                    
Install as a Cake Addin
#tool nuget:?package=Toon.DotNet&version=1.5.2
                    
Install as a Cake Tool

Toon Serializer for .NET

.NET 10.0.NET 9.0.NET 8.0NetStandard2.0

Token-Oriented Object Notation (TOON) Serializer — a compact, human-readable serialization format designed for passing structured data to Large Language Models with significantly reduced token usage. TOON shines for uniform arrays of objects and readable nested structures. Optimised for .Net 10.0 plus backwards compatible with earlier versions.

  • Token-efficient alternative to JSON for LLM prompts
  • Human-friendly and diff-friendly
  • Strongly-typed decode support via System.Text.Json
  • Strict validation options and round-trip helpers

License

How it works

TOON logo with step‑by‑step guide

Installation

Install from NuGet:

dotnet add package Toon.DotNet

Compatibility

  • .Net8.0
  • .Net9.0
  • .Net10.0
  • .Net Standard 2.0 (.NET Framework 4.6.1+, Mono and Unity)

Quick start

using ToonFormat;

var data = new {
 users = new[] {
 new { id =1, name = "Alice", role = "admin" },
 new { id =2, name = "Bob", role = "user" }
 }
};

// Encode to TOON
string toon = Toon.Encode(data);
// users[2]{id,name,role}:
//1,Alice,admin
//2,Bob,user

// Decode to JsonElement
var json = Toon.Decode(toon);

// Decode to a typed model
var users = Toon.Decode<UserData>(toon);

public class UserData { public User[] Users { get; set; } = Array.Empty<User>(); }
public class User { public int Id { get; set; } public string Name { get; set; } = ""; public string Role { get; set; } = ""; }

API overview

Basic Serilialization methods
  • Toon.Encode(object value, EncodeOptions? options = null)
  • Toon.Decode(string input, DecodeOptions? options = null)JsonElement
  • Toon.Decode<T>(string input, DecodeOptions? options = null, JsonSerializerOptions? jsonOptions = null)
Validation and Utilities
  • Toon.IsValid(string input, DecodeOptions? options = null)
  • Toon.RoundTrip(object value, EncodeOptions? encodeOptions = null, DecodeOptions? decodeOptions = null)
  • Toon.SizeComparisonPercentage<T>(T input, EncodeOptions? encodeOptions = null)
File operations
  • Toon.Save(object? value, string filePath, EncodeOptions? options = null)
  • Toon.Load<T>(string filePath, DecodeOptions? options = null, JsonSerializerOptions? jsonOptions = null)
  • Toon.Load(string filePath, DecodeOptions? options = null)

Options

EncodeOptions

  • Indent — spaces per level (default:2)
  • Delimiter — value delimiter for rows/inline arrays (default: ',')
  • LengthMarker — optional array length marker (e.g. '#')

DecodeOptions

  • Indent — expected spaces per level (default:2)
  • Strict — validate lengths/row counts and forbid stray blank lines

Customization example

var opts = new EncodeOptions {
 Indent =4,
 Delimiter = '|',
 LengthMarker = '#'
};
var toon = Toon.Encode(data, opts);

Size comparison example

// original data
var data = new[] {
 new { id =1, name = "Alice", role = "admin" },
 new { id =2, name = "Bob", role = "user" },
 new { id =3, name = "Charlie", role = "user" },
 new { id =4, name = "Dana", role = "admin" },
};

// encode with custom options
var encodeOptions = new EncodeOptions {  Indent = 2, Delimiter = '|' };
var toon = Toon.Encode(data, encodeOptions);
// => id|name|role
//   -+----+------+
//    1|Alice|admin |
//    2| Bob | user |
//    3|Charlie| user |
//    4| Dana |admin |

// get size comparison percentage
var pct = Toon.SizeComparisonPercentage(data, encodeOptions);
// ⇒ 28.57 (TOON is ~28.57% smaller than JSON for this data)


When to use TOON

  • Uniform arrays of objects (tabular data)
  • Human-readable prompt payloads for LLMs
  • Compact, copy/paste friendly format with stable structure

For deeply nested, highly irregular data, plain JSON may be more compact.


Package Dependencies

  • System.Text.Json (part of .NET)
  • Microsoft.SourceLink.GitHub (for source linking in PDBs)
  • NetStandard.Library (for .NET Standard 2.0 compatibility)

Samples

See examples/ToonFormat.Example for a runnable console sample.


Versioning

This project follows semantic versioning. See CHANGELOG.md for release notes.


Contributing

Contributions are welcome. See CONTRIBUTING.md and CODE_OF_CONDUCT.md.


Security

Please see SECURITY.md for reporting vulnerabilities.


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 was computed.  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 was computed.  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 (2)

Showing the top 2 NuGet packages that depend on Toon.DotNet:

Package Downloads
Toon.DotNet.Excel

Excel integration for ToonDotNet. Convert Excel workbooks and worksheets to and from TOON format.

Toon.DotNet.CSV

CSV integration for ToonDotNet. Convert CSV files to and from TOON format.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Toon.DotNet:

Repository Stars
Cysharp/ToonEncoder
High performance Token-Oriented Object Notation (TOON) encoder for .NET.
Version Downloads Last Updated
1.7.2 119 3/7/2026
1.7.1 350 2/25/2026
1.7.0 174 2/23/2026
1.6.1 2,588 1/16/2026
1.6.0 277 1/6/2026
1.5.2 106 1/5/2026
1.5.1 1,803 12/8/2025
1.5.0 940 12/1/2025
1.4.0 1,174 11/24/2025
1.3.0 201 11/24/2025
1.2.0 281 11/14/2025
1.1.0 263 11/14/2025
1.0.0 2,225 11/4/2025

See CHANGELOG.md for full release notes.