Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…
Cannot retrieve contributors at this time
81 lines (60 sloc) 1.4 KB


A prompt that asks for yaml input.


npm install yamlprompt or npm install -g yamlprompt



var yamlprompt = require('yamlprompt');
// Create readline interface
var rl = require('readline').createInterface(process.stdin, process.stdout);
rl.setPrompt('> ', 2);

yamlprompt(rl, function (err, obj) {
  if (err)
    throw err;

  // print the parsed yaml document

This will give you a prompt, where you can type in yaml and it will print the corresponding JS object. Stop parsing input by typing ....

$ node test.js
> key: value,
> array: [ some, values, in, an, array ]
> array2:
>   - 1
>   - 2
> indentation: |
>   indented
> ...
{ key: 'value',
  array: [ 'some', 'values', 'in', 'an', 'array' ],
  array2: [ 1, 2 ],
  indentation: 'indented' }

There is also a binary that can be used from the command line. It converts the YAML input to JSON.

$ yamlprompt
> key: value
> ...
  "key": "value"

You can redirect it's output to a file.

$ yamlprompt > output.json
> key: value
> ...

You can also pass one file to the prompt to let it act like a conversion tool.

$ yamlprompt test.yml > output.json

Bugs and Issues

If you encounter any bugs or issues, feel free to open an issue at github.


The MIT license.

Jump to Line
Something went wrong with that request. Please try again.