# Parsing and writing YAML

**URL:** <https://users.scala-lang.org/t/parsing-and-writing-yaml/10245>\
**Category:** Libraries\
**Created:** [September 24, 2024, 7:07pm UTC](https://users.scala-lang.org/t/parsing-and-writing-yaml/10245 "2024-09-24T19:07:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubaut](https://users.scala-lang.org/user_avatar/users.scala-lang.org/dubaut/32/1152_2.png) [@dubaut](https://users.scala-lang.org/u/dubaut)\
**Post date:** [September 24, 2024, 7:07pm UTC](https://users.scala-lang.org/t/parsing-and-writing-yaml/10245/1 "2024-09-24T19:07:01Z")

</div>

Is any library widely used in the Scala community to parse and write YAML files? What are you using to process YAML files?

---

<div class="post-metadata">

**Author:** ![OndrejSpanel](https://users.scala-lang.org/user_avatar/users.scala-lang.org/ondrejspanel/32/2318_2.png) [@OndrejSpanel](https://users.scala-lang.org/u/OndrejSpanel)\
**Post date:** [September 24, 2024, 8:01pm UTC](https://users.scala-lang.org/t/parsing-and-writing-yaml/10245/2 "2024-09-24T20:01:07Z")

</div>

I use [circe-yaml](https://github.com/circe/circe-yaml), it is mature, full featured, proven. For simple tasks [scala-yaml](https://github.com/VirtusLab/scala-yaml) is nice - esp. when you need Scala,js support. An interesting beast is a combination of the two - circe-yaml using scala-yaml as its backend, which gets you most circe functionality on Scala.js / native.

---

<div class="post-metadata">

**Author:** ![jducoeur](https://users.scala-lang.org/user_avatar/users.scala-lang.org/jducoeur/32/462_2.png) [@jducoeur](https://users.scala-lang.org/u/jducoeur)\
**Post date:** [September 24, 2024, 9:05pm UTC](https://users.scala-lang.org/t/parsing-and-writing-yaml/10245/3 "2024-09-24T21:05:01Z")

</div>

Less well-known, but almost uniquely versatile, is weePickle, a de/serialization library that translates smoothly in and out of several different formats: [GitHub - rallyhealth/weePickle: A fork of uPickle, shaded for backwards and forwards compatibility.](https://github.com/rallyhealth/weePickle)

(Disclaimer: I was involved in the original creation of weePickle, so I have a little ego-stake here, but haven’t been involved with the library for a long time. But I do quite love its design. It is a deep fork of Haoyi’s uPickle (also an excellent library), with a lot of pragmatic evolution in various ways. Caveat: it is JVM-specific, so not appropriate if you need to run on JS or Native.)

---

<div class="post-metadata">

**Author:** ![sageserpent-open](https://users.scala-lang.org/user_avatar/users.scala-lang.org/sageserpent-open/32/2576_2.png) [@sageserpent-open](https://users.scala-lang.org/u/sageserpent-open)\
**Post date:** [September 25, 2024, 7:42am UTC](https://users.scala-lang.org/t/parsing-and-writing-yaml/10245/4 "2024-09-25T07:42:15Z")

</div>

[circe-YAML in action](https://github.com/sageserpent-open/SemanticMergeScalaPlugin/blob/f599c11d649162752d0553e6654ca76779088aae/src/main/scala/com/sageserpent/neptunium/FileProcessor.scala#L382)

I’m a fan of Circe anyway for JSON, so it’s nice to use the same tool for YAML too. What I like about about Circe as opposed to say, Jackson is the perscriptive approach it takes to defining the structure of JSON - your Scala type definition is the the source of truth, rather than runtime reflection on the instance being serialised, or a set of heuristics about the best representation to deserialize an array of whatever at runtime. I’ve been bitten by round tripping issues before when using Jackson from Java and Scala.

That point is from JSON processing, but you may bump into similar issues with YAML.

---

<div class="post-metadata">

**Author:** ![micseydel](https://users.scala-lang.org/user_avatar/users.scala-lang.org/micseydel/32/89_2.png) [@micseydel](https://users.scala-lang.org/u/micseydel)\
**Post date:** [September 25, 2024, 4:01pm UTC](https://users.scala-lang.org/t/parsing-and-writing-yaml/10245/5 "2024-09-25T16:01:32Z")

</div>

Wow, thanks for sharing. I’ve been using Spray JSON in an Akka project and I’m excited to see if this can remove hundreds of lines of boilerplate.
