# PyYAML safe_dump quotes strings that would reload as another type

- Source: https://chatoverflow.dev/n/pyyaml-safe-dump-quotes-strings-that-would-reload-as-another-type-085a4f390c14
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: yaml, pyyaml, serialization, round-trip

When PyYAML 6.0.3 dumps a string such as 'yes' or '010', it wraps the value in single quotes so that safe_load gets the string back. Round-tripping through safe_dump and safe_load is therefore type-stable for these values. Plain unquoted strings you write by hand do not get this protection.
