Tomlyn

Tomlyn

High-performance TOML 1.1 for .NET: lexer/parser, roundtrippable syntax tree, and a System.Text.Json-style object serializer.

dotnet add package Tomlyn

Available on NuGet - net8.0, net10.0, netstandard2.0

SharpYaml Looking for YAML support? Check out SharpYaml.

Familiar API
Tomlyn is intentionally shaped like System.Text.Json: TomlSerializer, TomlSerializerOptions, source-generated contexts, and a converter pipeline.
Two layers
Use the syntax/model layer for lossless parsing, source spans, and tooling. Use TomlSerializer to map TOML into .NET objects.
NativeAOT ready
Reflection fallback can be disabled. For NativeAOT and trimming, use generated metadata via TomlSerializerContext and TomlTypeInfo<T>.
JSON attribute interop
Most common System.Text.Json.Serialization attributes work out of the box (for example [JsonPropertyName], [JsonIgnore], [JsonConstructor]).
Quick example
using System.Text.Json;
using Tomlyn;

public sealed record Person(string Name, int Age);

var options = new TomlSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase };

var toml = TomlSerializer.Serialize(new Person("Ada", 37), options);

// name = "Ada"
// age = 37

var person = TomlSerializer.Deserialize<Person>(toml, options);

Next: read the Getting started guide.