YAML supports multiple data types โ from simple text and numbers to lists and nested mappings. Hereโs a breakdown of the supported data types and how to write them.
๐ Example YAML with Different Data Types
Parsed keys and types will appear here...
๐ก Pro Tip: YAML auto-detects types. You can force types with tags (like !!str or !!int), but it's rarely needed.
๐ List of YAML Data Types
String: Text data (quoted or unquoted)
Integer: Whole numbers (e.g. 42)
Float: Decimal numbers (e.g. 3.14)
Boolean:true or false (lowercase)
Null:null, ~, or empty value
List: Multiple values using - prefix
Mapping: Key-value pairs (like a dictionary or object)
๐ Example: List of Booleans
๐ You can mix types inside lists, but itโs best practice to keep them consistent.
๐ Note About Quoting Strings
You can use quotes for strings when:
The string includes special characters like :, #, or @.
The string starts with a number but isnโt meant to be treated as a number.
๐ Conclusion
Thatโs YAMLโs data types in a nutshell โ super flexible, clean, and mostly auto-detected based on the content. Now you can write YAML config files with multiple types and nested structures confidently.