talira

.NET TOML 1.1 parser, round-trippable syntax tree and System.Text.Json-style serializer, NativeAOT ready

open sourceBSD-2-Clausefree

Tomlyn is a high-performance .NET parser for TOML 1.1, with a lossless, round-trippable syntax tree and an object serializer whose API follows System.Text.Json (TomlSerializer, TomlSerializerOptions). A source generator ships in the package for NativeAOT and trimming, and it can reuse System.Text.Json attributes. It targets net8.0, net10.0 and netstandard2.0, and installs from NuGet.

Problems it solves

  • I need to parse and write TOML config files in a .NET app.
  • edit a TOML file from C# without losing its comments and formatting
  • deserialize a TOML config into my C# classes in a NativeAOT app

Features

  • System.Text.Json-style serializer for TOML
  • lossless, trivia-preserving syntax tree for round-tripping files
  • source generator for NativeAOT and trimming
  • reuses System.Text.Json attributes such as JsonPropertyName

Limitations

  • Version 1 supports TOML 1.1.0 only, not TOML 1.0.1
  • Version 1 is a redesign with breaking changes from earlier versions.1