yaml.js

Standalone JavaScript YAML 1.2 parser and encoder for Node.js and browsers, with yaml2json and json2yaml command-line tools.

Library
npm
v0.3.0
885stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
36/100Needs Attention
Development Activity0
Maintenance0
Community64
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
45/100Fair
Architecture55
Code Quality45
Innovation25
Learning Curve55

yamljs is a standalone JavaScript YAML 1.2 parser and encoder that runs in Node.js and all major browsers without any native bindings. It converts YAML text into native JavaScript objects and back, with a parser and dumper implementation originally inspired by the Symfony YAML component.

Beyond the library API, yamljs ships two command-line tools — yaml2json and json2yaml — for converting files directly from the terminal, including recursive directory conversion and file-watching. The project has seen wide adoption as a lightweight YAML dependency, though its README now notes that active development has slowed and points users needing ongoing feature work and full spec compliance toward js-yaml instead.

What You Get

  • YAML.parse() to convert a YAML string into a native JavaScript object
  • YAML.stringify() / YAML.dump() to serialize a JavaScript object back into YAML text
  • YAML.load() / YAML.parseFile() to read and parse a .yml file synchronously or asynchronously
  • yaml2json and json2yaml command-line binaries for converting files without writing code

Common Use Cases

  • Reading YAML configuration files into a Node.js application at startup
  • Converting existing JSON config or data files to YAML for hand-editing, and back
  • Batch-converting a directory of YAML or JSON files from the command line with —recursive and —watch
  • Parsing YAML directly in browser-based tools without a build step or Node dependency

Under The Hood

Architecture Yaml.js is a thin facade delegating to Parser and Dumper classes for parse/dump respectively, with Inline.js handling flow-style scalar/collection parsing, Pattern.js centralizing regexes, Utils.js providing string/file helpers, and Escaper/Unescaper handling string quoting; the Exception/ directory defines ParseException, ParseMore, and DumpException for structured error reporting. Source is authored in CoffeeScript under src/ and compiled to lib/ via the Cakefile build system, so lib/*.js are generated artifacts rather than hand-written code. Parser.parse() is a single large stateful class walking lines with regex-driven context tracking rather than a token-stream/AST-based design, which is workable for typical config-sized YAML but harder to extend toward full spec conformance.

Tech Stack Written in CoffeeScript and compiled to plain JavaScript via the coffee compiler; runtime dependencies are argparse (CLI argument parsing for the yaml2json/json2yaml binaries) and glob (recursive directory matching for —recursive). Dev tooling includes benchmark, coffeeify (a Browserify CoffeeScript transform for the browser dist bundle), and jasmine-node for specs, with the whole build orchestrated through a Cakefile (cake build, cake test) rather than npm scripts. CI is configured via a legacy Travis config targeting Node 5.0 with globally installed coffeescript/browserify/uglify-js, and there is no lockfile or modern CI workflow.

Code Quality Tests live under test/spec/YamlSpec.coffee, run via jasmine-node through the Cakefile’s test task, with an extensive spec file covering parse/dump round-trips. Error handling uses dedicated typed exception classes (ParseException, DumpException, ParseMore) rather than generic throws, which is a good practice signal, but there is no static typing anywhere and no linter configuration in the repository — any tooling additions would need to target the CoffeeScript sources rather than the generated lib/ output.

What Makes It Unique Functionally yamljs is a fairly standard YAML parser/dumper, explicitly modeled on the Symfony YAML component, with no distinguishing technical approach beyond running from a single codebase in both Node.js and the browser without native bindings. The project’s own README now concedes that development has slowed and recommends js-yaml for users who need active maintenance and fuller spec compliance.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search