@ende/yaml

ende add jsr:@ende/yaml

Version 2026.10.15 on JSR.

parse and stringify for handling YAML encoded data.

Ported from js-yaml v3.13.1.

Use parseAll for parsing multiple documents in a single YAML string.

This package generally supports YAML 1.2.x (latest) and some YAML 1.1 features that are commonly used in the wild.

Supported YAML 1.1 features include:

Unsupported YAML 1.1 features include:

  • Yes, No, On, Off literals for bool type
  • Sexagesimal numbers (e.g. 3:25:45)
import { parse, stringify } from "@ende/yaml";
import { assertEquals } from "@ende/assert";

const data = parse(`
foo: bar
baz:
  - qux
  - quux
`);
assertEquals(data, { foo: "bar", baz: [ "qux", "quux" ] });

const yaml = stringify({ foo: "bar", baz: ["qux", "quux"] });
assertEquals(yaml, `foo: bar
baz:
  - qux
  - quux
`);

Limitations

  • binary type is currently not stable.

Modules

Exports

  • parse — Parse and return a YAML string as a parsed YAML document object.
  • parseAll — Same as parse, but understands multi-document YAML sources, and returns multiple parsed YAML document objects.
  • ParseOptions — Options for parse.
  • SchemaType — Name of the schema to use.
  • stringify — Converts a JavaScript object or value to a YAML document string.
  • StringifyOptions — Options for stringify.
  • StyleVariant — The style variation for `styles` option of stringify
  • YamlPosition — Position information for error reporting.
  • YamlSyntaxError — Error thrown when YAML parsing fails.