saneyaml
Serde-first YAML for Rust — load config straight into your structs with
#[derive(Deserialize)], with real YAML 1.2 semantics (so NO stays the
string "NO", not false), useful diagnostics, and resource limits built in.
Pure Rust, #![forbid(unsafe_code)].
Install
[]
= "0.1"
Then use it:
use ;
Coming from the archived serde_yaml? It's close to a drop-in — see
MIGRATION.md.
Why saneyaml
Most Rust YAML libraries make you pick one or the other: serde_yaml's
ergonomics (now archived, and YAML 1.1-flavored), or a maintained YAML 1.2
parser like yaml-rust2 or saphyr that hands you a node tree to walk by
hand. saneyaml is serde-first and YAML 1.2-correct.
- Serde-first —
from_str/from_slice/from_reader,to_string/to_writer, and aserde_yaml-styleValue. Deserialize straight into your config structs — no hand-walking a node tree. - YAML 1.2 by default — correct scalar resolution, no "Norway problem":
NO/on/off/yesstay strings. Opt into YAML 1.1 /serde_yaml-style resolution explicitly via schema modes (Core,Json,Failsafe,LegacySerdeYaml). - Diagnostics — line/column, in-document key path (e.g.
server.port), and opt-in source-caret rendering. - Safe on hostile input — unsafe-free, with bounded time and memory: input-size, alias-expansion, nesting-depth, scalar-length, and collection-size limits.
- Streaming and source-preserving edits — pull-based streaming
(
EventStream/DocumentStream) plusedit(...)for path-based config refactors that keep comments, anchors, ordering, and untouched bytes. - Benchmarked — real-world config corpus runs are tracked against
serde_yaml,yaml-rust2, andsaphyr; see BENCHMARKS.md.
Status
Pre-1.0 (0.2.0), MSRV Rust 1.88, and actively maintained. The public API is a
preview surface but is treated as SemVer-visible: breaking changes and MSRV
bumps are explicit, documented release decisions. The road to 1.0 is about
locking the surface down, not expanding it — stability is the goal.
Documentation
- MIGRATION.md —
serde_yamlmigration cookbook + support matrix - COMPATIBILITY.md — schema modes, scalar resolution, divergences, threat model
- ARCHITECTURE.md — crate layout and design
- BENCHMARKS.md · SECURITY.md · CONTRIBUTING.md · CHANGELOG.md
License
MIT — see LICENSE.md.