YamlDotNet 18.1.0

YamlDotNet

Appveyor NuGet
Build status NuGet

YamlDotNet is a YAML library for netstandard and other .NET runtimes.

YamlDotNet provides low level parsing and emitting of YAML as well as a high level object model similar to XmlDocument. A serialization library is also included that allows to read and write objects from and to YAML streams.

YamlDotNet's conformance with YAML specifications:

YAML Spec YDN Parser YDN Emitter
v1.1
v1.2

What is YAML?

YAML, which stands for "YAML Ain't Markup Language", is described as "a human friendly data serialization standard for all programming languages". Like XML, it allows to represent about any kind of data in a portable, platform-independent format. Unlike XML, it is "human friendly", which means that it is easy for a human to read or produce a valid YAML document.

The YamlDotNet library

The library has now been successfully used in multiple projects and is considered fairly stable. It is compatible with the following runtimes:

  • netstandard 2.0
  • netstandard 2.1
  • .NET 8.0
  • .NET 10.0
  • .NET Framework 4.7

Quick start

Here are some quick samples to get you started which can be viewed in this fiddle.

Serialization from an object to a string

using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;
...

 var person = new Person
{
    Name = "Abe Lincoln",
    Age = 25,
    HeightInInches = 6f + 4f / 12f,
    Addresses = new Dictionary<string, Address>{
        { "home", new  Address() {
                Street = "2720  Sundown Lane",
                City = "Kentucketsville",
                State = "Calousiyorkida",
                Zip = "99978",
            }},
        { "work", new  Address() {
                Street = "1600 Pennsylvania Avenue NW",
                City = "Washington",
                State = "District of Columbia",
                Zip = "20500",
            }},
    }
};

var serializer = new SerializerBuilder()
    .WithNamingConvention(CamelCaseNamingConvention.Instance)
    .Build();
var yaml = serializer.Serialize(person);
System.Console.WriteLine(yaml);
// Output: 
// name: Abe Lincoln
// age: 25
// heightInInches: 6.3333334922790527
// addresses:
//   home:
//     street: 2720  Sundown Lane
//     city: Kentucketsville
//     state: Calousiyorkida
//     zip: 99978
//   work:
//     street: 1600 Pennsylvania Avenue NW
//     city: Washington
//     state: District of Columbia
//     zip: 20500

Deserialization from a string to an object

using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;
...

var yml = @"
name: George Washington
age: 89
height_in_inches: 5.75
addresses:
  home:
    street: 400 Mockingbird Lane
    city: Louaryland
    state: Hawidaho
    zip: 99970
";

var deserializer = new DeserializerBuilder()
    .WithNamingConvention(UnderscoredNamingConvention.Instance)  // see height_in_inches in sample yml 
    .Build();

//yml contains a string containing your YAML
var p = deserializer.Deserialize<Person>(yml);
var h = p.Addresses["home"];
System.Console.WriteLine($"{p.Name} is {p.Age} years old and lives at {h.Street} in {h.City}, {h.State}.");
// Output:
// George Washington is 89 years old and lives at 400 Mockingbird Lane in Louaryland, Hawidaho.

More information

More information can be found in the project's wiki.

Installing

Just install the YamlDotNet NuGet package:

PM> Install-Package YamlDotNet

If you do not want to use NuGet, you can download binaries here.

YamlDotNet is also available on the Unity Asset Store.

Contributing

Please read CONTRIBUTING.md for guidelines.

Release notes

Please see the Releases at https://github.com/aaubry/YamlDotNet/releases

Showing the top 20 packages that depend on YamlDotNet.

Packages Downloads
NJsonSchema.Yaml
JSON Schema reader, generator and validator for .NET
162
NJsonSchema.Yaml
JSON Schema reader, generator and validator for .NET
205
NSwag.Core.Yaml
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
158
NSwag.Core.Yaml
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
159
NSwag.Core.Yaml
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
161
NSwag.Core.Yaml
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
162
NSwag.Core.Yaml
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
164
NSwag.Core.Yaml
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
216
NSwag.Core.Yaml
NSwag: The Swagger API toolchain for .NET and TypeScript
161
Nuke.Common
Cross-platform build automation system
155
Nuke.Common
Cross-platform build automation system
156
Nuke.Common
Cross-platform build automation system
157
Nuke.Common
Cross-platform build automation system
159
Nuke.Common
Cross-platform build automation system
162
Nuke.Common
Cross-platform build automation system
163
Nuke.Common
Cross-platform build automation system
164
Nuke.Common
Cross-platform build automation system Signed by signpath.io from repository 'https://github.com/nuke-build/nuke' commit '06168636a6c3d86bc83645fe5ef519ee17bf7233' (see contained AppVeyorSettings.json file for build settings).
164

.NET 10.0

  • No dependencies.

.NET Framework 4.7

  • No dependencies.

.NET 8.0

  • No dependencies.

.NET Standard 2.0

  • No dependencies.

.NET Standard 2.1

  • No dependencies.

Version Downloads Last updated
18.1.0 6 06/29/2026
18.0.0 15 05/21/2026
17.1.0 29 04/30/2026
17.0.1 32 04/10/2026
17.0.0 29 04/10/2026
16.3.0 190 12/27/2024
16.2.1 107 12/06/2024
16.2.0 113 11/12/2024
16.1.3 108 10/23/2024
16.1.2 117 09/20/2024
16.1.1 105 09/20/2024
16.1.0 106 09/20/2024
16.0.0 134 07/20/2024
15.3.0 127 07/20/2024
15.1.6 127 07/20/2024
15.1.4 147 07/20/2024
15.1.2 130 07/20/2024
15.1.1 128 07/20/2024
15.1.0 138 07/20/2024
13.7.1 134 02/13/2024
13.7.0 153 07/20/2024
13.5.2 138 07/20/2024
13.5.1 132 07/20/2024
13.5.0 153 07/20/2024
13.4.0 131 07/20/2024
13.3.1 141 07/20/2024
13.2.0 130 07/20/2024
13.1.1 137 07/20/2024
13.1.0 125 07/20/2024
13.0.2 146 07/20/2024
13.0.1 124 07/20/2024
13.0.0 126 07/20/2024
12.3.1 134 07/20/2024
12.3.0 138 07/20/2024
12.2.1 126 07/20/2024
12.2.0 132 07/20/2024
12.1.0 135 07/20/2024
12.0.2 128 07/20/2024
12.0.1 135 07/20/2024
12.0.0 127 07/20/2024
11.2.1 218 02/04/2024
11.2.0 126 07/20/2024
11.1.3-nullable-enums-0003 128 07/20/2024
11.1.1 140 07/20/2024
11.1.0 146 07/20/2024
11.0.1 148 07/20/2024
10.1.0 119 07/20/2024
10.0.0 140 07/20/2024
9.1.4 120 07/20/2024
8.1.2 142 07/20/2024
8.1.0 125 07/20/2024
8.0.0 144 07/20/2024
7.0.0 131 07/20/2024
6.1.2 137 07/20/2024
6.1.1 130 07/20/2024
6.0.0 119 07/20/2024
5.4.0 134 07/20/2024
5.3.1 115 07/20/2024
5.3.0 123 07/20/2024
5.1.0 137 07/20/2024