YAML Data Types Explained
YAML doesn't make you declare types the way a programming language does — it guesses, based on how a value is written. Most of the time that guessing works fine, but it's exactly where a few well-known surprises live.
Strings
Most text doesn't need quotes at all: city: Mumbai is a perfectly valid string. Quotes become necessary when the value could be mistaken for something else — a number, a boolean, or a value containing a colon.
Numbers
port: 8080 is parsed as an integer, and ratio: 0.75 as a float, automatically. The trap: version: 1.20 without quotes may get parsed as the number 1.2, silently dropping the trailing zero — if you mean a version string, quote it: version: "1.20".
Booleans
true, false, and — depending on the parser — yes, no, on, off can all be read as booleans. This is the single most famous YAML gotcha: a country code value like country: NO (Norway) can get silently parsed as the boolean false by parsers that follow the older YAML 1.1 spec. Quoting it — country: "NO" — avoids the whole problem.
Null
An empty value, the word null, or a tilde ~ are all read as null: middle_name:, middle_name: null, and middle_name: ~ are equivalent.
Dates
Values that look like 2026-01-15 are automatically parsed into date objects by many YAML libraries, not left as plain strings. This is usually helpful, but can surprise you if your program expected a string and got a date object instead — quote the value if you specifically want it treated as text.
Lists and maps
These aren't "primitive" types, but they're the two structural types everything else lives inside: a list (dash-prefixed items) and a map (indented key-value pairs), and either can be nested inside the other as deeply as you need.
If you're ever unsure how a specific value will actually be typed, the fastest way to check is to convert it to JSON with our tool — JSON's stricter type display (quotes around strings, no quotes around numbers and booleans) makes the guessed type obvious at a glance.