Skip to content
NEON decoder and encoder for JavaScript
Branch: master
Clone or download
Latest commit 1ddc15f May 18, 2017
Type Name Latest commit message Commit time
Failed to load latest commit information.
src decoder: fixed support for CRLF line-endings May 18, 2017
test decoder: fixed support for CRLF line-endings May 18, 2017
.gitignore refactored, added some tests (still failing) Sep 13, 2014
.travis.yml travis Sep 14, 2014
LICENSE Initial commit Sep 11, 2014 added readme Feb 22, 2015
package.json version 1.1.2 May 18, 2017

NEON-JS - NEON decoder and encoder for JavaScript

Build Status NPM version

NEON is very similar to YAML.The main difference is that the NEON supports "entities" (so can be used e.g. to parse phpDoc annotations) and tab characters for indentation. NEON syntax is a little simpler and the parsing is faster.

Example of Neon code:

# my web application config

	date.timezone: Europe/Prague
	zlib.output_compression: yes  # use gzip

	driver: mysql
	username: root
	password: beruska92

	- Dave
	- Kryten
	- Rimmer


NEON module for node.js

npm install neon-js

CLI executable is not available yet.

NEON for browser

You can create browser compatible library using browserify.

npm install browserify
browserify -r neon-js -s neon

You can found precompiled browserifed version in repository matej21/neon-js-dist.

<script src="dist/neon.js"></script>
<script type="text/javascript">
var data = neon.decode("hello: world")


var neon = require('neon-js');

try {
	var result = neon.decode("foo: {bar: 123}")
} catch (e) {
	if (e instanceof neon.Error) {
	throw e;


Decodes input NEON string.

var result = neon.decode(input);

encode(var[, options])

Encodes javascript to NEON.

var data = {foo: "bar"}
var result = neon.encode(data);
//or you can use block mode
var result = neon.encode(data, neon.BLOCK);


Class representing NEON entity.

var entity = neon.decode("Foo(bar)");
entity.value; "Foo";
entity.attributes// neon.Map instance, see bellow


NEON was originally written for PHP where all NEON array-like structures (lists, objects or mixed) were converted to the PHP array. And arrays in PHP are very powerful - they can be treated as a list, hash table and more. neon.Map is trying to keep the very basic of this behaviour - items are ordered (list) and can have string key (hash table). Therefore all NEON array-like structures are mapped to the neon.Map.

#example neon
foo: bar
- lorem
ipsum: dolor
- sit
var map = neon.decode(input);
//map instanceof neon.Map


Returns value by the key.

map.get("foo"); // bar
map.get(0); // lorem
map.get("xxx"); //throws an Error


Checks if the given key exists in the map.

map.has("foo"); // true
map.has("xxx"); // false


Calls provided function for every item in the map. Key is passed as a first argument, value as a second argument.

map.forEach(function (key, value) {



Checks if Map is a list. That means the map doesn't contain any string keys and numeric keys are in range 0..(length-1).

map.isList(); //false


Returns values as an array.

var values = map.values();
// ["bar", "lorem", "dolor", "sit"]


Returns keys as an array.

var keys = map.keys();
// ["foo", 0, "ipsum", 1]


Returns items structure. This structure is an array where every item is object with properties key and value.

var items = map.items();

// [{key: "foo", value: "bar"}, ...]


Converts Map to javascript object. Items order may be lost.

var obj = map.toObject();
// {foo: "bar", 0: "lorem", ipsum: "dolor", 1: sit}


Dumps decoded structure into simple text output as you can see in the demo.

var text = neon.Dumper.toText(data)`;


You can’t perform that action at this time.