The `yaml` library is a robust and definitive JavaScript parser and stringifier for YAML, supporting both YAML 1.1 and 1.2 specifications and all common data schemas. It currently maintains a stable version 2.8.3, with an active release cadence that regularly introduces new features and bug fixes. A v3.0.0-0 prerelease is also available under the `next` tag, though it is not yet stable for production use and is not recommended for production environments. Key differentiators include passing all `yaml-test-suite` tests, its ability to parse any string input without throwing errors (extracting as much YAML as possible), and comprehensive support for parsing, modifying, and writing YAML comments and blank lines. It boasts no external dependencies and runs across various JavaScript environments including Node.js (requiring `>= 14.6`), modern browsers, Deno, Bun, and Cloudflare Workers, shipping with full TypeScript type definitions (minimum TS 3.9).
npm install yamlVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates parsing multi-document YAML strings, modifying values and adding new items using the Document API, and then stringifying the result. It also shows parsing a single document with `parseDocument` and direct AST manipulation.
For v3 prereleases, always install with `npm install --save-exact yaml@next` to pin to a specific unstable version, or avoid using it in production until the final release.
Check the `engines.node` field in `package.json` for your specific `yaml` version or update Node.js to a version `>= 14.18` for broader compatibility within the v2 range.
Update your TypeScript compiler to version 3.9 or newer, or set `skipLibCheck: true` in your `tsconfig.json` to bypass type checking for declaration files (use with caution).
Adhere strictly to the documented API endpoints and classes. Avoid directly accessing private properties or methods which may be subject to change without a major version bump.
Update imports to use ESM syntax: `import { parse, stringify } from 'yaml'`.Ensure you are using named imports: `import { parse, stringify } from 'yaml'`.Update your Node.js environment to a version `>= 14.6` or higher to meet the package's engine requirements.
No dependency data recorded yet.