<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/how-compliant-is-psych-how-much-better-is-libfyaml--wkwon2hoa" -->

---
title: How Compliant Is Psych? How Much Better Is libfyaml?
description: A detailed conformance comparison examines how well Ruby's Psych YAML library adheres to the YAML spec, contrasting its libyaml backend against the newly added...
canonical: https://daily.dev/posts/how-compliant-is-psych-how-much-better-is-libfyaml--wkwon2hoa
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: How Compliant Is Psych? How Much Better Is libfyaml? | daily.dev
og:description: A detailed conformance comparison examines how well Ruby's Psych YAML library adheres to the YAML spec, contrasting its libyaml backend against the newly added...
og:url: https://daily.dev/posts/how-compliant-is-psych-how-much-better-is-libfyaml--wkwon2hoa
og:image: https://api.daily.dev/og/posts/wkWoN2HOA.png
og:image:alt: How Compliant Is Psych? How Much Better Is libfyaml?
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How Compliant Is Psych? How Much Better Is libfyaml?

**[Ruby Flow](https://daily.dev/sources/rubyflow)** · 21 min read · 1 upvotes · 0 comments

## Summary

A detailed conformance comparison examines how well Ruby's Psych YAML library adheres to the YAML spec, contrasting its libyaml backend against the newly added libfyaml backend (added to Psych on August 20, 2026). Testing against a 405-case YAML conformance suite, Psych with libyaml passes 315 cases (77.8%) while the libfyaml backend passes 403 (99.5%). The piece walks through numerous specific edge cases — directive handling, flow-context scalars starting with colons, anchors with unusual characters, line breaks in flow mappings, comment whitespace rules, and document start/end markers — comparing Psych's behavior against PyYAML, js-yaml, rapidyaml, and others across twelve parsers total. It concludes that while libfyaml is meaningfully more spec-compliant, most applications are unlikely to hit these edge cases, making the switch a judgment call rather than a necessity.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://durableprogramming.com/blog/how-compliant-is-psych>

## Questions this post answers

### How does Psych's new libfyaml backend compare to the default libyaml backend for YAML spec conformance?

Psych with its default libyaml backend passes 315 of 405 (77.8%) syntax conformance test cases, while the libfyaml backend added on August 20, 2026 passes 403 of 405 (99.5%). The libfyaml backend correctly handles unknown directives, flow-context scalars starting with colons, and unusual anchor names (including emoji and multi-byte characters) that libyaml rejects with errors.

_Weighing a switch between YAML parser backends in Ruby? daily.dev surfaces conformance and compatibility comparisons like this one._

### Does Psych in Ruby throw an error on unknown YAML directives like %UNKNOWNDIRECTIVE?

Yes, Psych's default libyaml-backed loader raises a Psych::SyntaxError on any unrecognized directive, even though the YAML 1.1 and 1.2 specs say unknown directives should be ignored with a warning rather than rejected. Only 3 of 12 tested parsers (Psych libyaml, PyYAML's CSafeLoader, and go-yaml) reject unknown directives; the libfyaml backend and 8 others accept them silently.

_Debugging YAML parsing errors across Ruby, Python, and Node? daily.dev tracks quirks like this that trip up interoperability._

### Can Psych parse a YAML flow-style value that starts with a colon, like {x: :x}?

No, Psych with the default libyaml backend raises a syntax error on {x: :x} because it treats the colon as a grammatical marker rather than part of the scalar value, despite YAML 1.1 §9.1.3 and YAML 1.2.2 §7.3.3 permitting values to start with a colon. Switching to the libfyaml backend fixes this and returns {"x" => :x} correctly.

_Hitting edge cases in YAML scalar parsing? daily.dev collects deep-dive comparisons like this for Ruby and cross-language config handling._

## Similar posts on daily.dev

- [A Ruby YAML parser](https://daily.dev/posts/a-ruby-yaml-parser-wuvkrt9ns) · RUBYLAND · 0 upvotes · 0 comments
- [GitHub - durable-oss/rapidyaml-rb](https://daily.dev/posts/github---durable-oss-rapidyaml-rb-19b1t7ftu) · Ruby Flow · 0 upvotes · 0 comments
- [Ruby May Finally Fix the Famous “Norway Problem”](https://daily.dev/posts/ruby-may-finally-fix-the-famous-norway-problem--hkkhy7rxd) · RUBYLAND · 2 upvotes · 0 comments
- [In Defense of YAML](https://daily.dev/posts/in-defense-of-yaml-0iiadtzpt) · Lobsters · 0 upvotes · 0 comments
- [YAML: The Language That Quietly Runs Modern DevOps](https://daily.dev/posts/yaml-the-language-that-quietly-runs-modern-devops-ojznade2q) · Medium · 1 upvotes · 0 comments

---

Tags: [#ruby](https://daily.dev/tags/ruby)

[View this post on daily.dev](https://daily.dev/posts/how-compliant-is-psych-how-much-better-is-libfyaml--wkwon2hoa)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"How Compliant Is Psych? How Much Better Is libfyaml?","url":"https://daily.dev/posts/how-compliant-is-psych-how-much-better-is-libfyaml--wkwon2hoa","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/how-compliant-is-psych-how-much-better-is-libfyaml--wkwon2hoa"},"datePublished":"2026-09-04T22:34:35.363Z","dateModified":"2026-09-13T21:49:36.991Z","description":"A detailed conformance comparison examines how well Ruby's Psych YAML library adheres to the YAML spec, contrasting its libyaml backend against the newly added...","image":"https://media.daily.dev/image/upload/s--58gMhC4P--/f_auto/v1722860399/public/Placeholder%2012","thumbnailUrl":"https://media.daily.dev/image/upload/s--58gMhC4P--/f_auto/v1722860399/public/Placeholder%2012","isAccessibleForFree":true,"articleSection":"Ruby Flow","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Ruby Flow","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/a21aaa8bcbbf448193a016895c90a0e1","url":"https://daily.dev/sources/rubyflow"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/how-compliant-is-psych-how-much-better-is-libfyaml--wkwon2hoa","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"ruby","timeRequired":"PT21M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Ruby Flow","item":"https://daily.dev/sources/rubyflow"},{"@type":"ListItem","position":3,"name":"How Compliant Is Psych? How Much Better Is libfyaml?"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/how-compliant-is-psych-how-much-better-is-libfyaml--wkwon2hoa#faq","mainEntity":[{"@type":"Question","name":"How does Psych's new libfyaml backend compare to the default libyaml backend for YAML spec conformance?","acceptedAnswer":{"@type":"Answer","text":"Psych with its default libyaml backend passes 315 of 405 (77.8%) syntax conformance test cases, while the libfyaml backend added on August 20, 2026 passes 403 of 405 (99.5%). The libfyaml backend correctly handles unknown directives, flow-context scalars starting with colons, and unusual anchor names (including emoji and multi-byte characters) that libyaml rejects with errors. Weighing a switch between YAML parser backends in Ruby? daily.dev surfaces conformance and compatibility comparisons like this one."}},{"@type":"Question","name":"Does Psych in Ruby throw an error on unknown YAML directives like %UNKNOWNDIRECTIVE?","acceptedAnswer":{"@type":"Answer","text":"Yes, Psych's default libyaml-backed loader raises a Psych::SyntaxError on any unrecognized directive, even though the YAML 1.1 and 1.2 specs say unknown directives should be ignored with a warning rather than rejected. Only 3 of 12 tested parsers (Psych libyaml, PyYAML's CSafeLoader, and go-yaml) reject unknown directives; the libfyaml backend and 8 others accept them silently. Debugging YAML parsing errors across Ruby, Python, and Node? daily.dev tracks quirks like this that trip up interoperability."}},{"@type":"Question","name":"Can Psych parse a YAML flow-style value that starts with a colon, like {x: :x}?","acceptedAnswer":{"@type":"Answer","text":"No, Psych with the default libyaml backend raises a syntax error on {x: :x} because it treats the colon as a grammatical marker rather than part of the scalar value, despite YAML 1.1 §9.1.3 and YAML 1.2.2 §7.3.3 permitting values to start with a colon. Switching to the libfyaml backend fixes this and returns {\"x\" =\u003e :x} correctly. Hitting edge cases in YAML scalar parsing? daily.dev collects deep-dive comparisons like this for Ruby and cross-language config handling."}}]}
```

