Bodu.Text.Toml 1.3.0

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

Bodu.Text.Toml

API stability - Stable. The public API surface is committed: breaking changes are reserved for a major-version bump per SemVer, except a deliberate break that is recorded in the release notes and in the package's CompatibilitySuppressions.xml. See versioning and support.

A TOML (v1.0.0 / v1.1.0) library for .NET 8 and .NET 10. It maps plain CLR objects to and from TOML through a configurable converter model, over a low-level forward-only token reader and writer, with both a mutable and a read-only document object model.

Installation

dotnet add package Bodu.Text.Toml

Targets net8.0 and net10.0.

API shape

The public surface follows the same System.Text.Json-shaped architecture as the sibling Bodu.Text.Bencode and Bodu.Text.Yaml libraries, so the patterns transfer directly between them; the options differ where the formats do (for example, PropertyNameCaseInsensitive defaults to false here and to true in Bencode). The types are organised into folders/namespaces by surface:

Type(s) Namespace Role
TomlSerializer / TomlSerializerOptions / TomlSerializerDefaults Bodu.Text.Toml Static serializer entry point, its configuration, and scenario presets (for example Web).
TomlTokenType, TomlValueKind Bodu.Text.Toml Token classification and value-kind classification (naming policies are the shared Bodu.Text.Serialization.NamingPolicy).
TomlFormatException / TomlSerializationException Bodu.Text.Toml Failures split by cause: malformed input vs. values that cannot be mapped.
Utf8TomlReader (+ TomlReaderOptions) Bodu.Text.Toml.Reader Forward-only, allocation-free ref struct token reader.
Utf8TomlWriter (+ TomlWriterOptions) Bodu.Text.Toml.Writer Forward-only ref struct token writer.
TomlDocument / TomlElement / TomlProperty Bodu.Text.Toml.Document Read-only, low-allocation document object model.
TomlNode / TomlObject / TomlArray / TomlValue Bodu.Text.Toml.Nodes Mutable document object model: parse, edit, write back.
TomlConverter<T> / TomlConverterFactory, TomlStringEnumConverter (+ generic) / TomlNumberEnumConverter<TEnum> Bodu.Text.Toml.Serialization Custom converters, converter factories, and the public enum converters; the per-member attribute family is the shared Bodu.Text.Serialization set ([PropertyName] / [Ignore] / [Converter] / …).
using Bodu.Text.Toml;

string toml = TomlSerializer.Serialize(new ServerConfig { Host = "localhost", Port = 8080 });
ServerConfig config = TomlSerializer.Deserialize<ServerConfig>(toml);

// Document object models
using Bodu.Text.Toml.Nodes;
TomlNode node = TomlNode.Parse(utf8Toml)!;
node["server"]!["port"] = 9090;
byte[] back = node.ToUtf8Bytes();
  • Value mapping: string/char/Guid/Uri → string, the integer family → integer, double/float → float, bool → boolean, and DateTimeOffset/DateTime/DateOnly/TimeOnly → the four RFC 3339 date-time forms; byte[] → an integer array (or a Base64 string via TomlSerializerOptions.ByteArrayHandling); enums → member-name strings. decimal maps to a float or, for full precision, a string (TomlSerializerOptions.DecimalHandling), and TimeSpan to its invariant "c"-format string.
  • A TOML document root must map to a table, so a top-level scalar or array throws. Output is normalized TOML in document order - deterministic for a given input, with member order preserved (so [PropertyOrder] is honored). It is not a canonical form: two equal documents built in different member orders serialize differently, so the output is unsuitable for hashing or signing.
  • The full serializer feature surface is present: converters and factories, the shared attribute family (PropertyName/Ignore/Converter/PropertyOrder/Constructor/Required/Include/ExtensionData/NamingPolicy/UnmappedMemberHandling/ObjectCreationHandling/StringEnumMemberName), the serialization callbacks (IOnSerializing / IOnSerialized / IOnDeserializing / IOnDeserialized), naming policies and TomlSerializerDefaults.Web, and the string/number enum converters.
  • Because the reader/writer/document types live in sub-namespaces, code that uses them alongside the serializer imports using Bodu.Text.Toml.Reader; / .Writer; / .Document; / .Nodes; as needed.
  • Failures surface through TomlFormatException (malformed input, with line/column/offset) and TomlSerializationException (binding failures).

Runnable samples

The repository ships offline, dotnet run-able sample projects for this package - the TomlSerializer POCO surface (temporal kinds, naming policies and attributes, the wire knobs) and the layers beneath it (both DOMs, the token reader/writer, streaming reads) - under samples/Text.Toml/.

Building and testing

To build this package from source and run its tests, see CONTRIBUTING.md.

License

MIT. © Bodu Pty. Ltd.

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 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. 
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 Bodu.Text.Toml:

Package Downloads
Bodu.Globalization.Calendar.Caching

Caching layer for Bodu.Globalization.Calendar. Provides CachingNotableDateService, a decorator that wraps any INotableDateService and serves computed notable dates from a per-territory, per-civil-year cache (in-memory or one TOML/JSON file per territory), recording when each year was computed and refreshing on a configurable time-to-live or a resource-version change. Includes the dependency-injection registration (AddCachedNotableDateService) on IServiceCollection.

Bodu.Financial.ExchangeRates.Caching

Caching layer for Bodu.Financial exchange-rate providers. Provides CachingRateProvider, a decorator that wraps any IDatedRateProvider and serves fresh rates from a shared on-disk cache (one TOML file per provider and currency pair), plus an AggregatingRateProvider (priority-fallback, averaging, per-pair routing). Includes the dependency-injection registrations (AddCachedRateProvider, AddAggregatedRateProvider) on IFinancialServiceBuilder.

Bodu.Extensions.Configuration.Text

The EditorConfig-compatible Microsoft.Extensions.Configuration provider. Bridges Bodu.Text.Configuration into the standard IConfiguration / IOptions<T> pipeline so a .boduconfig or bodu.config file registers with the same AddTextConfiguration(...) shape used for the JSON, INI, and XML providers - with file, stream, and programmatic-document overloads, reload-on-change, and colon-delimited section binding. Also ships the read-only TOML (AddTomlFile / AddTomlStream) and Bencode (AddBencodeFile / AddBencodeStream) sources.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.3.0 227 10/16/2026
1.0.0 1,353 9/24/2026
0.7.0 629 9/24/2026
0.6.0 177 9/24/2026
0.5.0 126 9/23/2026