js-yaml

A fast, complete YAML 1.2 and 1.1 parser and serializer for JavaScript.

Library
npm
v5.3.0
6,621stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
82/100Excellent
Development Activity96
Maintenance52
Community80
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
83/100Excellent
Architecture82
Code Quality85
Innovation84
Learning Curve82

js-yaml is a JavaScript implementation of a YAML parser and dumper that supports both the YAML 1.2 and legacy YAML 1.1 specifications, and passes the entire official YAML Test Suite. It exposes a small, focused API centered on load/loadAll for parsing and dump for serializing, with pluggable schemas (FAILSAFE, JSON, CORE, YAML11) that control which tags and types are recognized.

The library is widely used as the YAML engine inside build tools, linters, CI configuration loaders, and Node.js frameworks, and ships a minimal CLI for quick file inspection. Its only runtime dependency is argparse (used by the CLI), keeping the core parser dependency-free and easy to audit for supply-chain risk.

What You Get

  • load() and loadAll() functions for parsing single or multi-document YAML strings into JavaScript values
  • dump() for serializing JavaScript objects back into YAML with fine-grained formatting options (indentation, line width, quote style, key sorting)
  • Four built-in schemas (FAILSAFE, JSON, CORE, YAML11) plus a defineScalarTag/defineSequenceTag/defineMappingTag API for registering custom tags
  • A lower-level AST/event API (parseEvents, constructFromEvents, eventsToAst, present, visit) for tooling that needs to inspect or transform YAML structurally rather than just round-trip it
  • A minimal js-yaml CLI binary for converting/validating YAML files from the command line
  • Explicit safety controls (maxDepth, maxAliases, maxTotalMergeKeys) to guard against malicious or pathological YAML input

Common Use Cases

  • Loading configuration files (CI pipelines, linters, build tools) written in YAML
  • Serializing application data structures to human-editable YAML for config or fixture files
  • Building developer tooling (formatters, migration scripts, codegen) that needs to read or rewrite YAML while preserving structure via the AST/visit API
  • Safely parsing untrusted or user-submitted YAML with depth/alias limits to avoid billion-laughs-style denial-of-service inputs

Under The Hood

Architecture: js-yaml is organized as a clean pipeline of independent stages rather than a monolithic parser. src/parser/parser.ts (1,469 lines) tokenizes and parses raw YAML text into a flat stream of Event objects (document/sequence/mapping/scalar/alias/pop), which src/parser/constructor.ts then folds into native JavaScript values via constructFromEvents. A parallel path (src/ast/from_events.ts, src/ast/nodes.ts, src/ast/visit.ts) turns the same event stream into a mutable AST that tooling can traverse and rewrite, and src/ast/presenter.ts (1,011 lines) re-serializes that AST back to YAML text for dump(). This event-stream-as-common-currency design is what lets load, loadAll, dump, and the lower-level AST utilities in src/index.ts all share one core engine instead of duplicating parsing logic.

Tech Stack: The library is authored entirely in TypeScript (58% of bytes per GitHub’s language breakdown) and builds to dual CJS/ESM output (dist/js-yaml.cjs.js, dist/js-yaml.mjs) plus a browser UMD/ESM bundle, configured via package.json’s exports map. The only runtime dependency is argparse (used solely by the bin/js-yaml.mjs CLI); the core parser/serializer has zero runtime dependencies. The build pipeline uses Rollup with rollup-plugin-dts for type bundling, and tsc --noEmit for standalone type-checking.

Code Quality: Test coverage is substantial and multi-layered: 30 *.test.mjs files under test/core/ (split into units/, tags/, ast/, common/ subdirectories) cover individual tag types and API units, test/core/dump-fuzzy.test.mjs fuzz-tests the serializer, and test/core/pathological.test.mjs targets adversarial/edge-case input. test/spec/ runs the library against the full external YAML Test Suite (fetched via support/get-yaml-test-suite.mjs), giving spec-conformance coverage beyond hand-written unit tests. Linting is enforced via neostandard (an ESLint config), and the npm test script chains lint, build, type-check, and both test suites — a CI-strict pipeline that would fail on any regression.

API Design: The public surface is deliberately narrow — load/loadAll for parsing, dump for serialization — with sensible defaults (CORE_SCHEMA, no complex-key support by default) that cover the common case with minimal ceremony, while advanced needs (custom tags, complex map keys via realMapTag, structural rewriting via visit) are opt-in through documented escape hatches. Options objects are typed and merged against explicit DEFAULT_LOAD_OPTIONS/DEFAULT_PARSER_OPTIONS constants, and safety-relevant options (maxDepth, maxAliases) are surfaced prominently in the README rather than buried in advanced docs, reflecting a design that treats untrusted-input handling as a first-class concern.

Used by 96 apps in this directory

TypeScript
88%
Other

AFFiNE

Productivity · Project Management · Note Taking

71,668

Write, draw, and plan in one infinite canvas — the open-source alternative to Notion and Miro that keeps your data yours.

View details
91
Repo Health
87
Technical
68
Dependency
Built with
TypeScript88%
Updated today
TypeScript
59%
Other

agenta

Developer Tools · Devops · AI Development

4,489

The open-source LLMOps platform unifying prompt engineering, evaluation, and observability for teams building reliable LLM applications.

View details
91
Repo Health
77
Technical
67
Dependency
Built with
TypeScript59%
Python39%
Updated today
Rust
64%
Apache 2.0

agentgateway

AI Development · Developer Tools

4,420

An open source AI-native proxy that secures, observes, and governs agent-to-LLM, agent-to-tool, and agent-to-agent communication through MCP, A2A, and unified LLM routing.

View details
88
Repo Health
82
Technical
72
Dependency
Built with
Rust64%
Go24%
Updated yesterday
Python
49%
Other

Airbyte

Developer Tools · Data Engineering

21,916

Open-source ELT platform with 600+ connectors for moving data from any source to warehouses, lakes, and AI agents.

View details
95
Repo Health
80
Technical
67
Dependency
Built with
Python49%
Kotlin42%
Updated today
TypeScript
72%
AGPL 3.0

APITable

Low Code Platforms · Databases

15,526

API-first collaborative spreadsheet-database platform that auto-generates REST APIs and lets teams build internal tools, CRMs, and dashboards without code.

View details
53
Repo Health
77
Technical
60
Dependency
Built with
TypeScript72%
Java22%
Updated 9 months ago
TypeScript
51%
MIT

Anarlog

Note Taking · AI Assistants · Productivity

9,087

Anarlog is an open-source, local-first AI meeting notetaker that records, transcribes, and summarizes meetings entirely on your device — no cloud lock-in, no mandatory account, and every note saved as a plain markdown file you own forever.

View details
86
Repo Health
77
Technical
69
Dependency
Built with
TypeScript51%
Rust38%
Updated today
JavaScript
94%
MIT

Another Redis Desktop Manager

Developer Tools · Databases

34,643

Fast, stable Redis GUI with cluster, SSH, and massive key support

View details
84
Repo Health
56
Technical
67
Dependency
Built with
JavaScript94%
Updated yesterday
Go
60%
Apache 2.0

Apache Answer

Community

15,652

Open-source Q&A platform for communities, help centers, and knowledge bases with AI assistant and plugin extensibility

View details
85
Repo Health
78
Technical
69
Dependency
Built with
Go60%
TypeScript36%
Updated 2 days ago
TypeScript
49%
MPL 2.0

Artillery

Devops · Developer Tools

9,054

Cloud-scale load testing and functional testing for APIs, WebSockets, gRPC, and headless browsers, distributed across AWS Lambda or Fargate with zero infrastructure to manage.

View details
89
Repo Health
73
Technical
68
Dependency
Built with
TypeScript49%
JavaScript48%
Updated 5 days ago

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