Pure Javascript YAML loader and dumper, ported from PyYAML


yaml-js is a YAML loader and dumper, ported pretty much line-for-line from PyYAML. The goal for the project is to maintain a reliable and specification-complete YAML processor in pure Javascript, with CoffeeScript source code. You can try it out here.

The library is being actively maintained for issues, and rather less actively developed for new/improved features.

Loading is stable and well-used, and passes the yaml-spec test suite, which fairly thoroughly covers the YAML 'core' schema (if you notice anything missing, create an issue).

Dumping is present but very lightly tested (auto-tests only, no significant usage). The output should therefore be correct YAML, however formatting is currently entirely untested.

If you use the library and find any bugs, or have any suggestions, don't hesitate to create an issue.

npm install yaml-js


yaml = require 'yaml-js'
console.log yaml.load '''
    - hello
    - &world world
    - goodbye
    - *world
  phrase3: >
    What is up
    in this place.
# { phrase1: [ 'hello', 'world' ], 
#   phrase2: [ 'goodbye', 'world' ], 
#   phrase3: 'What is up in this place.' } 


yaml = require 'yaml-js'
console.log yaml.dump
  phrase1: [ 'hello',   'world' ]
  phrase2: [ 'goodbye''world' ]
  phrase3: 'What is up in this place.'
# phrase1: [hello, world] 
# phrase2: [goodbye, world] 
# phrase3: What is up in this place. 
<script src='yaml.min.js'></script>
  console.log(yaml.load('hello: world'));
  // { 'hello' : 'world' } 
  console.log(yaml.dump({ hello: 'world' }));
  // 'hello: world\n'