Prettier Plugin for Properties Files
raw JSON → 0.3.1 verified Sat Apr 25 auth: no javascript
A Prettier plugin that adds support for formatting .properties files, version 0.3.1, with a stable release cadence and active maintenance. It integrates with Prettier v2.3 and later, providing dedicated formatting for Java-style property files. Key differentiators include support for escape non-Latin-1 characters (for ISO-8859-1 encoding) and customizable key-value separators (space, colon, equals with various spacing). Unlike generic formatters, this plugin understands the .properties syntax, handling comments, multi-line values, and Unicode escaping correctly.
Common errors
error Cannot find module 'prettier-plugin-properties' ↓
cause Plugin not installed or not in node_modules.
fix
Run npm install --save-dev prettier-plugin-properties
error Configuration file contains a plugin that is not installed: prettier-plugin-properties ↓
cause Plugin listed in .prettierrc but missing from node_modules.
fix
Install the plugin or remove it from the plugins array.
error TypeError: Cannot read properties of undefined (reading 'properties') ↓
cause The plugin expects a valid .properties file but the file is empty or malformed.
fix
Ensure the file has at least one key-value pair or comment.
Warnings
breaking Prettier v3 no longer autoloads plugins. You must explicitly list plugins in config. ↓
fix Add 'prettier-plugin-properties' to the plugins array in .prettierrc or use --plugins in CLI.
gotcha Plugin only works with Prettier >= 2.3.0 and Node.js >= 18 (v0.3.0+). ↓
fix Upgrade Prettier to 2.3+ and Node to 18+.
deprecated v0.2.0 dropped runtime dependency on linguist-languages, but configuration remains the same. ↓
fix No action needed; upgrade to v0.2.0 or later.
gotcha Features like escapeNonLatin1 only affect non-Latin-1 characters; Latin-1 characters (e.g., ñ) are left as-is. ↓
fix Use escapeNonLatin1: true to force escape of all non-Latin-1 characters.
Install
npm install prettier-plugin-properties yarn add prettier-plugin-properties pnpm add prettier-plugin-properties Imports
- plugin wrong
import plugin from 'prettier-plugin-properties'correct// In .prettierrc: plugins: ['prettier-plugin-properties'] - escapeNonLatin1 wrong
import { escapeNonLatin1 } from 'prettier-plugin-properties'correct// In .prettierrc: { escapeNonLatin1: true } - keySeparator wrong
const { keySeparator } = require('prettier-plugin-properties')correct// In .prettierrc: { keySeparator: ' = ' }
Quickstart
// Install
npm install --save-dev prettier prettier-plugin-properties
// .prettierrc
{
"plugins": ["prettier-plugin-properties"],
"keySeparator": " = ",
"escapeNonLatin1": false
}
// Run
npx prettier --write file.properties
// file.properties input
name = John Doe
age=30
key with spaces: value
\u00e9\u00e0
// file.properties output
name = John Doe
age = 30
key with spaces = value
\u00e9\u00e0