YamlDotNet 16.3.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 6.0
  • .NET 8.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
KubernetesClient
Client library for the Kubernetes open source container orchestrator.
4
KubernetesClient
Client library for the Kubernetes open source container orchestrator.
3
SummerBoot
将SpringBoot的先进理念与C#的简洁优雅合二为一,声明式编程,专注于”做什么”而不是”如何去做”。在更高层面写代码,更关心的是目标,而不是底层算法实现的过程,SummerBoot,致力于打造一个人性化框架,让.net开发变得更简单优雅。
3
NJsonSchema.Yaml
JSON Schema reader, generator and validator for .NET
2
NSwag.Core.Yaml
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
2
Ocelot
Ocelot Api Gateway
2
SummerBoot
将SpringBoot的先进理念与C#的简洁优雅合二为一,声明式编程,专注于”做什么”而不是”如何去做”,在更高层面写代码。SummerBoot,致力于打造一个易上手,好维护的人性化框架,让大家早点下班去做自己喜欢的事。Combining the advanced concepts of SpringBoot with the simplicity and elegance of C#, declarative programming focuses on "what to do" rather than "how to do it", and writes code at a higher level. SummerBoot is committed to creating an easy-to-use and easy-to-maintain humanized framework, so that everyone can get off work early to do what they like.
2
UAParser
A .net wrapper for the ua-parser library
2
Elsa.Core
Elsa is a set of workflow libraries and tools that enable lean and mean workflowing capabilities in any .NET Core application. This package contains the core of Elsa. Tip: reference the `Elsa` package instead of this one.
2
NSwag.Core.Yaml
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
1
Elsa.Core
Elsa is a set of workflow libraries and tools that enable super-fast workflowing capabilities in any .NET Core application. This package contains the heart and soul of what makes Elsa tick. It implements most of the abstractions defined in Elsa.Abstractions. If you reference the Elsa package, which is recommended, you don;t have to explicitly reference this package.
1
Elsa.Core
Elsa is a set of workflow libraries and tools that enable lean and mean workflowing capabilities in any .NET Core application. This package contains the core of Elsa. Tip: reference the `Elsa` package instead of this one.
1

.NET Framework 4.7

  • No dependencies.

.NET 6.0

  • No dependencies.

.NET 8.0

  • No dependencies.

.NET Standard 2.0

  • No dependencies.

.NET Standard 2.1

  • No dependencies.

Version Downloads Last updated
16.3.0 1 2025/5/31
16.2.1 0 2024/12/1
16.2.0 0 2024/11/10
16.1.3 1 2025/6/7
16.1.2 0 2024/9/13
16.1.1 1 2025/6/6
16.1.0 0 2024/9/1
16.0.0 0 2024/7/14
15.3.0 2 2025/5/25
15.1.6 0 2024/5/29
15.1.4 1 2025/6/7
15.1.2 1 2025/6/7
15.1.1 0 2024/2/4
15.1.0 0 2024/1/23
13.7.1 0 2023/10/15
13.7.0 2 2025/5/25
13.5.2 0 2023/10/5
13.5.1 2 2025/5/26
13.5.0 0 2023/10/5
13.4.0 0 2023/9/20
13.3.1 1 2025/6/7
13.2.0 0 2023/8/14
13.1.1 0 2023/6/17
13.1.0 2 2025/5/24
13.0.2 0 2023/3/11
13.0.1 0 2023/2/19
13.0.0 0 2023/2/7
12.3.1 1 2025/6/6
12.3.0 0 2022/12/19
12.2.1 1 2025/6/6
12.2.0 0 2022/12/9
12.1.0 0 2022/12/5
12.0.2 0 2022/10/7
12.0.1 1 2025/6/7
12.0.0 0 2022/7/23
11.2.1 1 2025/6/6
11.2.0 0 2021/6/13
11.1.3-nullable-enums-0003 1 2025/6/1
11.1.1 1 2025/6/6
11.1.0 2 2025/5/24
11.0.1 1 2025/6/7
10.1.0 0 2021/3/31
10.0.0 0 2021/3/27
9.1.4 0 2021/1/15
8.1.2 1 2025/6/7
8.1.0 2 2025/5/24
8.0.0 2 2025/5/25
7.0.0 0 2019/9/28
6.1.2 2 2025/5/25
6.1.1 0 2019/6/4
6.0.0 0 2019/3/15
5.4.0 2 2025/5/25
5.3.1 1 2025/5/29
5.3.0 0 2018/12/5
5.1.0 0 2018/9/21