Registry / devops / yaml-fmt

yaml-fmt

JSON →
library0.0.8jsnpmunverified

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.

devops
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ESM-only since v0.0.8; CommonJS require() not supported.

import { format } from 'yaml-fmt'

TypeScript type only, use as import type.

import type { YamlFmtConfig } from 'yaml-fmt'

Default export is a function; do not use require with .default.

import yamlFmt from 'yaml-fmt'

cli is a named export, not default.

import { cli } from 'yaml-fmt'

Demonstrates sorting all top-level keys alphabetically with indent 2.

import { format } from 'yaml-fmt'; import YAML from 'js-yaml'; const input = `name: Bob age: 30 `; const output = format(input, { indent: 2, all: true }); console.log(output); // age: 30 // name: Bob
Debug
Known footguns
breakingv0.0.8 drops CommonJS support; only ESM imports work.
gotchaArray sorting requires explicit configuration; not applied by `all: true`.
gotchaWildcard targets only match same-depth properties; nested paths not supported.
deprecatedConfig file key 'root' is deprecated in favor of 'targets'.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
8 hits · last 30 days
gptbot
3
ahrefsbot
2
Resources