1. License
“Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.”
ISC allows any use, with or without a fee.
github.com/eemeli/yaml/blob/v2.9.1/LICENSE3. Used by agents' projects
Dependency in 214 public GitHub projects set up for AI coding agents that we scanned (3.4%).
4. Agent access
Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.
From the package registry and GitHub, checked daily; card checked Nov 10, 2026. Tap a verdict to see its source.How we checkedReport an error
What yaml does
yaml is a free JavaScript library that reads and writes YAML, the plain-text format many settings files are written in. Your app or script can load such a file, change one value and save it back with the comments people wrote still in place. It works in Node.js and in modern browsers.
What people build with it
Load a settings file
A Node.js script or server reads its settings from a YAML file and gets plain JavaScript objects and lists back.
Change a value, keep the comments
Your tool bumps a port or a version number in a hand-written settings file, and the notes people left in it stay where they were.
Save app data as a readable file
An export button or a generator script writes settings or content as YAML that a person can open and edit by hand.
Point to the broken line
When a person pastes or uploads a broken settings file, your app shows which line and column are wrong instead of a vague failure.
Read older files the old way
Files written for older tools treat words like yes, no and on as true or false; you can tell yaml to read them by the older rules.
A settings editor in the browser Idea
An admin page lets people edit a YAML settings file right in the browser and checks it before saving, with no server step.
yaml popularity
Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated
How yaml is used
- yaml is a dependency in 214 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (4.4% of the 4,867 JavaScript/TypeScript ones), #5 of 408 in utilities.
- Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 607; those are left out of every share on this page.
- The most used alternative in our scan is js-yaml (143 projects).
- Projects that use it most often also use Vitest (63.6%), tsx (52.8%), TypeScript (88.8%).
- It is more common in projects set up for OpenClaw (15.0%) than for Cursor (2.6%).
By coding agent
Often used with
yaml in practice
Strengths
The README lists support for parsing, modifying and writing YAML comments and blank lines among the library's core features.
The README claims support for YAML 1.1 and 1.2 with all common data schemas. It also claims the library passes every test in the yaml-test-suite.
According to the README, the first layer "just works" and the second adds "all the bells and whistles supported by the library". The third gets progressively closer to the YAML source.
The README says <code>parse</code> and <code>stringify</code> work like their JSON counterparts "as far as possible". They also take reviver and replacer arguments.
Watch out for
The docs say <code>YAML.parse</code> throws on error and may log warnings with <code>console.warn</code>. It only accepts a single YAML document. For multi-document input, use <code>parseAllDocuments</code>.
FormatArc reports that a Helm-style value starting with <code>{{</code> produced no error in eemeli/yaml. The parser silently returned a mangled object. The post gives two fixes: quote the whole value, or validate only after the template is rendered.
The README says the minimum TypeScript version for the typings is 5.9. The docs site says 3.9. The README says the library accepts "any string" without throwing, while the site says "nearly any string". The README installs <code>yaml@next</code> with <code>--save-exact</code>, and the site uses plain <code>npm install yaml</code>.
parse and stringify, from the README
import { parse, stringify } from 'yaml'
parse('[ true, false, maybe, null, 3.14159 ]')
// [ true, false, 'maybe', null, 3.14159 ]
stringify([true, false, 'maybe', null, 3.14159])
// `- true
// - false
// - maybe
// - null
// - 3.14159
// `
stringify({ number: 3, plain: 'string', block: 'two\nlines\n' })
// `number: 3
// plain: string
// block: |
// two
// lines
// `More about yaml
Funding
- GitHub Sponsors: https://github.com/eemeli
- Tidelift: https://tidelift.com/funding/github/npm/yaml
- 4 GitHub sponsors
Head to head
- yaml vs js-yaml used together in 13 projects
Packages around it
- vitest: Test runner
- tsx: Run TypeScript in Node
- typescript: Typed JavaScript compiler
- zod: Schema validation
- @modelcontextprotocol: MCP SDK
- chalk: Terminal colors
Alternatives
yaml This page
Pick js-yaml when you only need to read and write YAML in JavaScript and do not need to keep comments when you save.
Pick PyYAML when your code is in Python rather than JavaScript.
Pick gray-matter when the YAML sits at the top of Markdown files, such as blog posts, and you need both parts.
Get started
Tell your AI assistant
“Use the npm package yaml (pin yaml@2.9.1, Node.js 14.6+) to read config.yml with parseDocument, change the value with doc.setIn, and write doc.toString() back so the comments stay; catch YAMLParseError and show its line and column.”
Add the package to your project (version 2; the GitHub front page already describes the next major version).
npm install yamlImport parse and stringify; they work like the built-in JSON functions.
import { parse, stringify } from 'yaml'From eemeli.org/yaml/
To edit a file and keep its comments, parse it as a document instead.
import { parseDocument } from 'yaml'From eemeli.org/yaml/
Rules for your agent
## yaml
- Use `parse` / `stringify` from `yaml` for plain reads and writes. Reviver and replacer arguments follow the JSON implementation.
- Handle errors around `YAML.parse`: it throws on error and may log warnings with `console.warn`.
- Use `parseAllDocuments` for input with more than one YAML document. `parse` only supports a single document.
- To write a stream of documents, call `stringify` once per document value and join the results with `...\n`. Each `stringify` result already ends with `\n`.
- Pass one options object to every call, since option categories do not overlap. Use `intAsBigInt: true` to get BigInt integers, or `schema: 'failsafe'` to keep scalars as strings.
- Do not rely on undocumented internals. They may change between minor versions.
- If the bundled typings fail on an older TypeScript compiler, set `skipLibCheck: true`.
Mistakes to avoid
The main branch already describes the version 3 prerelease, which needs a newer Node.js.
parse returns plain data without comments; the Document keeps them (our demo kept both comments).
Default rules are YAML 1.2; in our run NO stayed "NO" and became false only with version: '1.1'.
parse supports one document per input.
The limit is what stops alias-expansion files from exhausting memory.
Questions
Can I use it in a paid, closed-source app?
Yes. The ISC license allows any use with or without a fee; keep the copyright and license notice.
Does it keep comments when I save a file?
Yes, if you edit through parseDocument and save with toString(); the quick parse and stringify functions give plain data without comments.
Why does NO (Norway) or yes stay text?
By default yaml reads files by the YAML 1.2 rules, where only true and false are true or false. Pass version '1.1' to read files written for older tools.
Does it run in the browser?
Yes. It has no other packages it depends on and runs in Node.js and in modern browsers.
Is it maintained?
Yes. Version 2.9.1 was published on 11 September 2026, and a version 3 is in prerelease.