YAML for Java. A user-friendly OOP library.
Switch branches/tags
Nothing to show
Clone or download
Latest commit 8155afa Sep 20, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
rcfg new rcfg Sep 12, 2018
src #135 renamed camel to eo-yaml Sep 10, 2018
.0pdd.yml 0pdd config + unit tests Jan 19, 2017
.gitattributes Add .yml eol to .gitattributes Jun 15, 2018
.gitignore Update .gitignore Dec 28, 2016
.rultor.yml Update .rultor.yml Jul 22, 2018
.travis.yml Update .travis.yml Dec 8, 2017
LICENSE year update Jan 5, 2017
README.md 2.0.2-SNAPSHOT Sep 20, 2018
checkstyle.xml #135 renamed camel to eo-yaml Sep 10, 2018
pom.xml 2.0.2-SNAPSHOT Sep 20, 2018
rrv.sh #135 rename to eo-yaml Sep 10, 2018




PDD status Build Status Coverage Status

DevOps By Rultor.com We recommend IntelliJ IDEA

YAML for Java. A user-friendly OOP library. Based on spec 1.2.

From the specification: YAML™ is a human-friendly, cross language, Unicode based data serialization language.

To get the latest release, simply add the following to your pom.xml:


or download the fat jar.


The API of this library is clean, intuitive and generally close to the javax.json API that most developers are used to:


Since the library is quite young, it doesn't support all the features of YAML yet. For now, it only supports creating/parsing Block Style YAML, so use it if you have to read/create configuration files and such stuff. It doesn't yet implement features such as flow or recursive representation, aliases & anchors or document streams (more YAMLs separated by ---).

However, keep in mind that the library is based on interfaces and OOP best practices, so you can probably extend/decorate the objects in order to create the functionality you need!

If you have some time and like the library, please consider contributing.

Building and printing Yaml:

YamlMapping yaml = Yaml.createYamlMappingBuilder()
    .add("architect", "amihaiemil")

toString() methods are overriden to pretty-print the yaml, so the above yaml.toString() will print:

architect: amihaiemil
  - amihaiemil
  - salikjan
  - SherifWally
  - rultor
  - 0pdd


Reading a Yaml input is very straight-forward, as outlined bellow. There is one important aspect: the input has to be a valid (well-indented) Yaml, otherwise you will get an exception, at some point, when trying to work with the read object!

//createYamlInput is overloaded to accept also String InputStream
YamlMapping yamlMapping = Yaml.createYamlInput(new File("mapping.yml"))

YamlSequence yamlSequence = Yaml.createYamlInput(new File("sequence.yml"))

Parsing a Pojo:

Pojos can be parsed ("dumped") into Yaml as follows (attributes need to have getters and setters):

Map<String, Integer> grades = new HashMap<>();
grades.put("Math", 9);
grades.put("CS", 10);
YamlMapping studentYaml = new YamlObjectDump(
    new Student ("John", "Doe", 20, grades)

studentYaml.toString() will print:

age: 20
firstName: John
  CS: 10
  Math: 9
lastName: Doe

You can also parse maps (Map<Object, Object>) and collections (Collection<Object>) using YamlMapDump and YamlCollectionDump respecitvely


Contributors are welcome

  1. Open an issue regarding an improvement you thought of, or a bug you noticed, or ask to be assigned to an existing one.
  2. If the issue is confirmed, fork the repository, do the changes on a separate branch and make a Pull Request.
  3. After review and acceptance, the PR is merged and closed.
  4. You are automatically listed as a contributor on the repo and the project's site (to follow)

Make sure the maven build

$ mvn clean install -Pcheckstyle

passes before making a PR.