Skip to content
Agents tracked: 506 Releases (7d): 634 Agent status: 4 with issuesSince last limit reset: Claude 15d · Codex 0d For AI agents: Markdown Updated Nov 26, 2026

yaml

Read, write and edit YAML files in JavaScript.

UtilitiesNPM

GitHubWebsite

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/LICENSE

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

70 / 100
Gid Score, #385 overall
33M
downloads a week, npm
1,705
GitHub stars
214
agent projects use it
yaml: downloads per weeknpm, yaml 330,301,968
yaml: GitHub starseemeli/yaml 1,705

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

171 projects, 5.2%
92 projects, 3.0%
63 projects, 2.6%
50 projects, 15.0%
36 projects, 7.6%
33 projects, 7.0%
21 projects, 6.1%
10 projects, 3.6%

Often used with

In 63.6% of its projects
In 52.8% of its projects
In 88.8% of its projects
In 29.0% of its projects
In 54.2% of its projects
In 28.0% of its projects
In 27.6% of its projects

yaml in practice

Strengths

Comments and blank lines survive

The README lists support for parsing, modifying and writing YAML comments and blank lines among the library's core features.

Passes the yaml-test-suite, per the maintainers

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.

Three depths of API

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.

Familiar JSON-style entry point

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

parse() throws and takes one document

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>.

Unrendered {{ }} templates come back mangled, with no error

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.

README and docs site disagree

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

See all

Head to head
Packages around it
  • vitest: Test runner
  • tsx: Run TypeScript in Node
  • typescript: Typed JavaScript compiler
  • zod: Schema validation
  • @modelcontextprotocol: MCP SDK
  • chalk: Terminal colors
More in Utilities

Alternatives

yaml This page

ISCGid 7033M/wk

js-yaml

Pick js-yaml when you only need to read and write YAML in JavaScript and do not need to keep comments when you save.

MITGid 73409M/wk

PyYAML

Pick PyYAML when your code is in Python rather than JavaScript.

gray-matter

Pick gray-matter when the YAML sits at the top of Markdown files, such as blog posts, and you need both parts.

Compare yaml with another tool

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.”

  1. Add the package to your project (version 2; the GitHub front page already describes the next major version).

    npm install yaml

    From github.com/eemeli/yaml/blob/v2.9.1/README.md

  2. Import parse and stringify; they work like the built-in JSON functions.

    import { parse, stringify } from 'yaml'

    From eemeli.org/yaml/

  3. 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

Paste into AGENTS.md or CLAUDE.md
## 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

Following the GitHub main-branch README (npm install --save-exact yaml@next) in a project on yaml 2
npm install yaml (2.9.1) and read the yaml@2 documentation site linked from the package

The main branch already describes the version 3 prerelease, which needs a newer Node.js.

stringify(parse(file)) to change one value in a hand-written config
parseDocument(file), doc.setIn([...], value), then doc.toString()

parse returns plain data without comments; the Document keeps them (our demo kept both comments).

Expecting yes, no, on or NO to come back as true or false (old YAML 1.1 habit)
Write true or false in the file, or parse with { version: '1.1' } for old files

Default rules are YAML 1.2; in our run NO stayed "NO" and became false only with version: '1.1'.

parse() on a file with several documents separated by ---
parseAllDocuments(file) and read each document

parse supports one document per input.

Setting maxAliasCount to -1 for files that users upload
Keep the default limit (100) for any input you do not control

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.