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
Find this tool useful? Support the project to keep it free!
Buy me a coffeeWhat 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
Paste YAML into the input panel.
Set a root class name (optional).
Choose a namespace or leave blank.
Toggle JSON property attributes and nullable types.
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.
name: Alice
age: 30
active: truepublic 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.
Related Tools
JSON to C# Converter
Generate C# classes from a JSON example. Infers types, creates nested classes, handles arrays as List<T>, and optionally emits [JsonPropertyName] attributes for System.Text.Json.
YAML to JSON Converter
Convert YAML to JSON and JSON to YAML — for config files, CI pipelines, and Kubernetes manifests.
YAML to Dart Converter
Generate Dart classes from a YAML example. Supports nullable types, final fields, fromJson/toJson factories, and nested class generation for mappings.
YAML to Go Struct Converter
Generate Go structs from a YAML example. Infers types, creates nested structs, handles arrays as slices, and emits json:"..." tags ready for encoding/json or yaml.v3.
YAML Validator
Validate YAML syntax online. Shows valid/invalid status with exact error line and column, plus structure stats for valid documents.
YAML Beautifier
Format and prettify YAML with configurable indentation and optional key sorting. Validates YAML syntax instantly.

