prettier-plugin-ini
raw JSON → 1.3.0 verified Sat Apr 25 auth: no javascript
A Prettier plugin for formatting INI configuration files. Current stable version is 1.3.0, released under the MIT License. It integrates seamlessly with the Prettier ecosystem and supports common formatting options such as printWidth, tabWidth, and a unique iniSpaceAroundEquals option for adding spaces around equals signs. It is actively maintained on GitHub and follows Prettier's release cadence. Compared to alternative INI formatters, it leverages Prettier's robust parser infrastructure and editor integrations, ensuring consistent styling across projects.
Common errors
error Cannot find module 'prettier-plugin-ini' ↓
cause Plugin not installed or not in node_modules.
fix
Run npm install --save-dev prettier-plugin-ini and ensure it's in your project.
error No parser specified for file extension '.ini' ↓
cause Prettier not configured to use the plugin for INI files.
fix
Add the plugin to your Prettier config: { "plugins": ["prettier-plugin-ini"] }
Warnings
gotcha Plugin requires Prettier v2+; using with older Prettier may fail silently. ↓
fix Update Prettier to version 2.x or higher.
gotcha The iniSpaceAroundEquals option can break compatibility with tools that expect no spaces around equals. ↓
fix Ensure your configuration aligns with downstream parsers.
Install
npm install prettier-plugin-ini yarn add prettier-plugin-ini pnpm add prettier-plugin-ini Imports
- default wrong
const prettier = require('prettier')correctimport prettier from 'prettier' - ensureEndOfLine
import { ensureEndOfLine } from 'prettier-plugin-ini'
Quickstart
// Install: npm install --save-dev prettier prettier-plugin-ini
// Format INI files via CLI:
// prettier --write '**/*.ini'
// Or with options:
// prettier --ini-space-around-equals --tab-width 4 --write 'config.ini'
// Programmatic usage (ESM):
import prettier from 'prettier';
const code = `[section]
key=value`;
const formatted = await prettier.format(code, {
parser: 'ini',
plugins: ['prettier-plugin-ini'],
iniSpaceAroundEquals: true,
tabWidth: 2
});
console.log(formatted);