CalcCafe

YAML to C#

Paste YAML and instantly generate C# class definitions with inferred property types.

Example

Input YAML:

name: Ada
age: 36
address:
 city: London
roles:
 - admin
 - editor

Output C#:

public class Root
{
  public string Name { get; set; }
  public long Age { get; set; }
  public Address Address { get; set; }
  public List<string> Roles { get; set; }
}

public class Address
{
  public string City { get; set; }
}

How it works

The tool parses your YAML with js-yaml, infers a type model from the resulting value, and emits idiomatic C# classes. Nested objects become their own classes and arrays become List<T> properties.

Good to know

YAML to C# turns a YAML document into ready-to-paste C# class definitions by reading your actual data and inferring a property type for every key. It is aimed at .NET developers who receive configuration files, API fixtures, or CI/CD manifests in YAML and want a strongly-typed model to deserialize into without hand-writing each class. The whole conversion happens locally in your browser, so nothing you paste is sent to a server.

Reach for it when you are wiring up a deserializer (for example with YamlDotNet or after converting YAML to JSON), scaffolding a settings POCO from an existing config, or just want a quick mental map of a file's shape. Paste your YAML, click Convert, and the output pane fills with the generated classes; the root container is always named Root, nested mappings each get their own class, and the editorial sample button gives you a realistic structure to experiment with.

To read the result, scan how each scalar was typed and how the structure was decomposed. The inference rules are deliberately simple and worth knowing before you trust the output:

The biggest caveat is that types reflect only the sample you paste, not the schema's intent. An empty list becomes List<object>, a missing-on-this-instance field simply will not appear, and nothing is ever marked nullable, so review numeric widths and add ? or attributes where your real data allows nulls or larger integers. Paste a representative, fully-populated example for the most accurate model.

Frequently asked questions

How are numeric types chosen?
Whole numbers become long and numbers with a decimal point become double. If a list mixes integers and decimals the property is widened to double so every value fits.
What happens with nested objects and lists of objects?
Each nested mapping becomes its own C# class, and a list of mappings becomes Listwhere T is a generated class named from the singular of the property (for example projects yields a Project class).
Is my data uploaded anywhere?
No — this tool runs entirely in your browser. Your input never leaves your device and it works offline once loaded.
Is it free?
Yes, completely free with no sign-up and no limits.

People also ask

What C# type does YAML to C# use for dates or timestamps?
It does not have a dedicated date type. A YAML value like a date is treated as a string and emitted as a string property, so you would change it to DateTime or DateTimeOffset manually after generating the class.
How does the generated C# handle null or empty YAML values?
A null value falls back to the object type, and an empty list becomes List<object> because there is no element to infer from. The tool never marks properties as nullable, so add ? to value types where nulls are possible.
Can I use the output directly with YamlDotNet?
Yes. The generated classes are plain POCOs with public auto-properties, which YamlDotNet can populate via its deserializer. You may want to add naming-convention configuration since the YAML keys are converted to PascalCase property names.
Why is everything wrapped in a class called Root?
The top-level YAML mapping is always emitted as a class named Root so there is a single, predictable entry point to deserialize into. You can rename it to match your domain after copying the output.
Does the tool generate properties or fields?
It generates auto-implemented properties using the get and set accessor syntax, for example public string Name { get; set; }, rather than public fields.
Will it correctly singularize irregular plural property names?
It handles common English patterns such as -ies to -y and -s to singular, so categories becomes Category and roles becomes Role. Irregular plurals like children may not singularize correctly, so rename those classes by hand.
Is there a size limit on the YAML I can convert?
There is no enforced limit because the conversion runs entirely in your browser. Practical limits depend on your device's memory and the browser's handling of very large text inputs.

Related tools