Prettier is an opinionated code formatter that supports JavaScript, TypeScript, CSS, JSON, Markdown, YAML, and more via plugins. Current stable version is 3.4.2, released monthly. It parses code and reprints it with its own rules, enforcing consistent style and handling line wrapping. Key differentiators: zero configuration, automatic formatting on save, editor integrations, and a vast plugin ecosystem. It is widely adopted in the JavaScript ecosystem.
npm install prettierrNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to format a string of JavaScript code using Prettier API with custom options.
Update Node.js to >=10. Review formatting changes and possibly set trailingComma: 'es5' and arrowParens: 'avoid' in config.
Use --write to overwrite files and --check for CI. stdin is implicit.
Upgrade to v2+ or use --no-config.
Run 'npm install prettier' and ensure import is 'import { format } from 'prettier'' (no './' prefix).Change import to 'prettier' instead of './prettier'.
Use 'import { format } from 'prettier'' or 'import prettier from 'prettier'; prettier.format(...)'.Install prettier via npm and use 'const prettier = require('prettier')'.No dependency data recorded yet.