| title | Home |
|---|---|
| layout | simple |
| og_type | website |
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], and [JsonObjectCreationHandling]).
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.
