WebToolsPlanet
Converter Tools

YAML to C# Converter

Paste a YAML document and get C# classes with typed properties, optional JSON annotations, and namespace support.

Last updated: May 28, 2026

Client-Side Processing
Input Data Stays on Device
Instant Local Execution

Find this tool useful? Support the project to keep it free!

Buy me a coffee

What is YAML to C# Converter?

This tool converts YAML to a C# class hierarchy. It parses YAML into JSON internally, then generates C# classes that mirror the document structure. Nested mappings become nested classes, sequences become List<T>, and scalar values are typed as string, int, double, or bool.

How to Use YAML to C# Converter

1

Paste YAML into the input panel.

2

Set a root class name (optional).

3

Choose a namespace or leave blank.

4

Toggle JSON property attributes and nullable types.

5

Copy the generated C# code.

Common Use Cases

  • Generating C# models for a .NET service that deserializes YAML configs.
  • Typing Kubernetes or Helm values in a .NET operator.
  • Scaffolding model classes before writing YAML serialization code.
  • Converting API YAML examples to C# DTOs.

Example Input and Output

A small YAML mapping becomes a C# class.

YAML input
name: Alice
age: 30
active: true
Generated C# class
public class Root
{
    [JsonPropertyName("name")]
    public string Name { get; set; }

    [JsonPropertyName("age")]
    public int Age { get; set; }

    [JsonPropertyName("active")]
    public bool Active { get; set; }
}

Tip

Add System.Text.Json or Newtonsoft.Json using directives when using the generated [JsonPropertyName] attributes.

Frequently Asked Questions

How are YAML sequences handled?
YAML sequences (lists) become List<T> properties where T is inferred from the first list item.
How are scalars typed?
true/false become bool, integers become int, decimals become double, and strings become string.
Is the YAML sent to a server?
No. All YAML parsing and C# generation happen entirely in your browser.