A configurable YAML formatter for Node.js (CLI & API) that sorts object keys and array values in YAML files. Currently at v0.0.8, with infrequent releases. Key differentiators include support for wildcard targets, property-specific sort configurations, and JSON-based config files. Provides ESM and CJS support, ships TypeScript types, and can be used as a CLI tool via `yaml-fmt fmt` or programmatically. Alternatives like prettier or yq offer broader functionality but less YAML-specific sorting control.
npm install yaml-fmtNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates sorting all top-level keys alphabetically with indent 2.
Switch to import statements; use dynamic import if needed.
Define array sort targets in config (e.g., "properties.enumValue.enum.[]": true).
Use explicit paths for deep nesting.
Move root sort config under 'targets' as 'root': true or array.
Run 'npm install yaml-fmt' and ensure Node.js >=12 (ESM support).
Use import { format } from 'yaml-fmt' (ESM only).Use -a (short flag) or ensure version >=0.0.6.