js-yaml

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

Library
npm
v5.4.3
6,638 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
82 /100 Excellent
Development Activity 96
Maintenance 52
Community 80
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
83 /100 Excellent
Architecture 82
Code Quality 85
Innovation 84
Learning Curve 82

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 101 apps in this directory

TypeScript
94%
Apache 2.0

NemoClaw

AI Agents · AI Development

22,690

Run AI coding agents like OpenClaw and Hermes securely inside NVIDIA OpenShell sandboxes with a hardened blueprint, routed inference, and lifecycle management through a single CLI.

View details
79
Repo Health
87
Technical
71
Dependency
Built with
TypeScript 94%
Updated today
Go
74%
Other

Notifuse

Marketing

2,240

Open-source, self-hosted alternative to Mailchimp, Brevo, and Klaviyo — send newsletters and transactional emails without per-email pricing or vendor lock-in.

View details
81
Repo Health
80
Technical
65
Dependency
Built with
Go 74%
TypeScript 23%
Updated 1 weeks ago
TypeScript
95%
MIT

OmniRoute

AI Agents

74,725

A free, open-source AI gateway connecting Claude Code, Codex, Cursor, Cline, and Copilot to 237 AI providers (90+ free) through one endpoint, with automatic fallback and token-compression to stretch free-tier limits further.

View details
86
Repo Health
70
Technical
70
Dependency
Built with
TypeScript 95%
Updated today
TypeScript
96%
Apache 2.0

OneUptime

Monitoring

7,719

The complete open-source observability platform that replaces PagerDuty, Datadog, Sentry, and StatusPage with a single self-hostable system.

View details
91
Repo Health
81
Technical
65
Dependency
Built with
TypeScript 96%
Updated today
TypeScript
39%
AGPL 3.0

OpenObserve

Analytics · Devops · Monitoring

22,312

Open source observability platform for logs, metrics, traces, and real user monitoring — delivering 140x lower storage costs than Elasticsearch with a single binary you can run in under 2 minutes.

View details
90
Repo Health
9
Technical
71
Dependency
Built with
TypeScript 39%
Rust 30%
Vue 17%
Updated today
TypeScript
88%
AGPL 3.0

OpenPanel

Analytics

7,111

Open-source Mixpanel alternative with session replay, MCP integration, and privacy-first product analytics you fully control.

View details
75
Repo Health
74
Technical
65
Dependency
Built with
TypeScript 88%
MDX 10%
Updated yesterday
TypeScript
97%
Other

Outline

Collaboration · Knowledge Management

40,855

A fast, real-time collaborative knowledge base for growing teams built on React, Node.js, and ProseMirror.

View details
91
Repo Health
87
Technical
68
Dependency
Built with
TypeScript 97%
Updated today
JavaScript
64%
AGPL 3.0

overleaf

Collaboration · Productivity

18,220

Open-source, real-time collaborative LaTeX editor with sandboxed compilation and full TeXLive support for self-hosted academic and research teams.

View details
86
Repo Health
80
Technical
59
Dependency
Built with
JavaScript 64%
TypeScript 30%
Updated 3 weeks ago
TypeScript
99%
AGPL 3.0

Pangolin

Networking

23,042

An open-source, identity-based zero-trust remote access platform built on WireGuard — a self-hostable alternative to Cloudflare Tunnel and Twingate with SSO, OIDC, and tunneled reverse proxying.

View details
87
Repo Health
68
Technical
68
Dependency
Built with
TypeScript 99%
Updated today

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