Registry / devops / prettier-plugin-yaml

prettier-plugin-yaml

JSON →
library1.1.3jsnpmunverified

A Prettier plugin providing additional YAML formatting options beyond Prettier's built-in support. Current stable version is 1.1.3. It adds options like yamlBlockStyle, yamlCollectionStyle, yamlQuoteKeys, and yamlQuoteValues. Released under MIT, it has a frequent release cadence with 6+ versions. Key differentiators: no dependencies beyond Prettier 3+, TypeScript types included, and addresses CVE-2026-33532 in the underlying yaml library. It is ESM-only and requires Node >=20.

npm install prettier-plugin-yaml
INSTALL
IMPORT
SIG · PRETTIER-PLUGIN-YA
P
prettier-plugin-yaml
devopsjavascriptv1.1.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

Plugin
import { Plugin } from 'prettier-plugin-yaml'
const Plugin = require('prettier-plugin-yaml')
The package is ESM-only. Import named exports; no default export exists since v1.1.2.
options
import { options } from 'prettier-plugin-yaml'
const { options } = require('prettier-plugin-yaml')
Options object with TypeScript types; use named import.
PluginOptions
import type { PluginOptions } from 'prettier-plugin-yaml'
import { PluginOptions } from 'prettier-plugin-yaml'
PluginOptions is a type, not a value. Use type import for correct TypeScript usage.

Shows installation, configuration with yamlQuoteKeys option, and usage with npx.

// Install: npm install --save-dev prettier prettier-plugin-yaml // Add to .prettierrc: { "plugins": ["prettier-plugin-yaml"], "yamlQuoteKeys": true } // Then run: npx prettier --write file.yaml
Debug
Known issues
breakingThe package is ESM-only. Use `import` syntax, not `require()`, and ensure `"type": "module"` in package.json or use .mjs extension.
fix
Add `"type": "module"` to your package.json or use .mjs files when importing the plugin programmatically.
affects: >=1.0.0
breakingThe `Plugin` named export was incorrectly re-exported as a non-interface in v1.1.1. This was fixed in v1.1.2.
fix
Upgrade to v1.1.2 or later: npm install prettier-plugin-yaml@latest
affects: 1.1.1
deprecatedAll options are stable; no known deprecations as of v1.1.3.
fix
No action needed.
affects: >=1.0.0
gotchaIf using other YAML Prettier plugins, prettier-plugin-yaml must be listed last in the plugins array to take effect.
fix
Ensure other YAML plugins appear before prettier-plugin-yaml in the plugins array.
affects: >=1.0.0
gotchaThe yamlQuoteValues option does not apply to strings that are valid numeric or boolean representations; those remain unquoted.
fix
If you need all strings quoted, consider using yamlQuoteValues with additional manual overrides.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: The 'Plugin' interface was incorrectly exported
Using v1.1.1 where the Plugin export was malformed.
fix
Update to v1.1.2+: npm install prettier-plugin-yaml@1.1.2
Error [ERR_REQUIRE_ESM]: require() of ES Module
Attempting to use require() on an ESM-only package.
fix
Use import syntax or set type: module in package.json.
Error: Cannot find module 'prettier-plugin-yaml'
Plugin not installed or not configured in Prettier config.
fix
Run npm install --save-dev prettier-plugin-yaml and add 'prettier-plugin-yaml' to the plugins array in .prettierrc.
Upgrade
Version history
1.1.3latest on npm
Audit
Dependencies
prettierrequiredPeer dependency; the plugin requires Prettier version 3 or higher to function.
Agent activity
9 hits · last 30 days
node
8
Amazon
1
Resources
prettier-plugin-yaml — npm install prettier-plugin-yaml · libregistry