1. Andrey Somov
  2. snakeyaml


Clone wiki

snakeyaml / Home


YAML 1.1 parser and emitter for Java.


SnakeYAML requires Java 6 or higher. (The source depends on Java 5, but the build targets Java 6.)

SnakeYAML does not depend on any external library (but the tests do).


Quick start

Loading (de-serialize):

Yaml yaml = new Yaml();
Object obj = yaml.load("a: 1\nb: 2\nc:\n  - aaa\n  - bbb");

{b=2, c=[aaa, bbb], a=1}

Dumping (serialise):

Map<String, String> map = new HashMap<String, String>();
map.put("name", "Pushkin");
Yaml yaml = new Yaml();
String output = yaml.dump(map);

name: Pushkin

For more details, please check Documentation


The SnakeYAML library is developed by the team of developers and it is based on PyYAML module written by Kirill Simonov.

SnakeYAML is released under the Apache 2.0 license.

Wiki features

This wiki uses the Markdown syntax.

The wiki itself is actually a mercurial repository, which means you can clone it, edit it locally/offline, add images or any other file type, and push it back to us. It will be live immediately.

Go ahead and try:

$ hg clone https://asomov@bitbucket.org/asomov/snakeyaml/wiki

Wiki pages are normal files, with the .md extension. You can edit them locally, as well as creating new ones.

Syntax highlighting

You can also highlight snippets of text (we use the excellent Pygments library).

Here's an example of some Python code:

def wiki_rocks(text):
    formatter = lambda t: "funky"+t
    return formatter(text)

You can check out the source of this page to see how that's done, and make sure to bookmark the vast library of Pygment lexers, we accept the 'short name' or the 'mimetype' of anything in there.

Have fun!