A Prettier plugin for formatting Angular HTML templates by aligning attributes on multiple lines using minimum line breaks, sorting attributes by category (ref, structural, twoWay, input, output, animation, static, boolean), outputting self-closing elements, and formatting Angular control flow blocks (@if, @for, etc.). Current stable version is 0.3.2, released on npm with Prettier >=3.0.0 as a peer dependency. Key differentiators include attribute alignment strategies (single-line, aligned, fallback), configurable attribute order via angularAttributeOrder, and built-in handling of Angular-specific syntax. Ships TypeScript type declarations.
npm install prettier-plugin-angularVerified import paths — ran on the pinned version, not inferred.
Install and configure the plugin for Angular HTML template formatting with attribute sorting enabled.
Upgrade Prettier to version 3.0.0 or higher: npm install -D prettier@^3.0.0
Add overrides in .prettierrc targeting '*.html' with parser 'angular-attributes' as shown in quickstart.
Ensure components do not depend on whitespace children. Use <ng-content> explicitly.
Add "angularAttributeSort": false to the overrides options.
Extract inline templates to separate .html files for formatting.
Run: npm install -D prettier-plugin-angular. Ensure package.json includes it in devDependencies.
Add "plugins": ["prettier-plugin-angular"] to .prettierrc.
Upgrade Prettier to version 3.0.0 or later: npm install -D prettier@^3.0.0
Use overrides to set parser to 'angular-attributes' for .html files as shown in quickstart.