To install:
npm install yaml@next
# or
yarn add yaml@next
yaml
is a new definitive library for YAML, a human friendly data serialization standard. This library:
- Supports all versions of the standard (1.0, 1.1, and 1.2),
- Passes all of the yaml-test-suite tests,
- Can accept any string as input without throwing, parsing as much YAML out of it as it can, and
- Supports parsing, modifying, and writing YAML comments.
The library is released under the ISC open source license, and the code is available on GitHub. It has no external dependencies and runs on Node.js as well as modern browsers.
For the purposes of versioning, any changes that break any of the endpoints or APIs documented here will be considered semver-major breaking changes. Undocumented library internals may change between minor versions, and previous APIs may be deprecated (but not removed).
Note: These docs are for yaml@2
. For v1, see the v1.10.0 tag for the source and eemeli.org/yaml/v1 for the documentation.
The API provided by yaml
has three layers, depending on how deep you need to go: Parse & Stringify, Documents, and the CST Parser. The first has the simplest API and "just works", the second gets you all the bells and whistles supported by the library along with a decent AST, and the third is the closest to YAML source, making it fast, raw, and crude.
import YAML from 'yaml'
// or
const YAML = require('yaml')
YAML.Document
YAML.parseAllDocuments(str, options?): YAML.Document[]
YAML.parseDocument(str, options?): YAML.Document
YAML.visit(node, visitor)
import { Pair, YAMLMap, YAMLSeq } from 'yaml'