What does Prettier do for Angular templates?
Prettier with the Angular plugin parses an Angular template into the AST emitted by @angular/compiler and re-prints it with consistent indentation, attribute wrapping, and quote style. This pretty printer is lighter — it does string-based tag indentation only, which is enough for a quick readability pass on a template copied from DevTools or a Stack Overflow answer. For project-wide enforcement, install Prettier with --plugin=prettier-plugin-organize-attributes.
How are structural directives like *ngFor and *ngIf handled?
Structural directives are attribute-form syntactic sugar that Angular desugars into <ng-template>. The formatter treats *ngFor and *ngIf as ordinary attributes — they stay on the host element with their full microsyntax (let item of items; trackBy: trackById; let i = index) on a single line. The element they decorate is indented under its parent; the directive itself is not turned into a separate template wrapper.
Does it preserve property bindings and event handlers?
Yes. [prop]="value" property bindings, (event)="handler($event)" event bindings, [(ngModel)]="x" two-way bindings, and [class.active]="cond" / [style.color]="c" host bindings are kept verbatim with their square-bracket and parenthesis syntax. The formatter never rewrites attribute values — it only normalises whitespace between tags and indentation around them.
How does it handle ng-template, ng-container, and ng-content?
These are first-class Angular elements and indent the same way as a div or section. <ng-template> blocks referenced by template variables (#empty, #loading) are emitted on their own indented lines; <ng-container *ngIf="..."> groups without rendering an extra DOM node and indents normally; <ng-content select="..."> projects content in a component template and indents under the host.
Will this format my Angular component TypeScript file?
No. This tool focuses on the template (the inline or external template/templateUrl HTML). To format the @Component decorator class with TypeScript-aware indentation, use the TypeScript Formatter instead — it handles decorators, generic type parameters, dependency injection in constructors, and lifecycle hooks (ngOnInit, ngOnDestroy, OnChanges).
Does it handle inline templates inside @Component({ template: `...` })?
For a component file, copy only the template literal contents (between the backticks of template:) into the formatter. Pasting the whole .ts file would reformat the TypeScript surrounding the template too, which is not what you want — Angular templates and TypeScript have different brace and quote rules.
Is the Angular code I paste sent to your servers?
No. Formatting runs entirely in your browser using JavaScript. Templates containing API endpoints, internal route paths, feature-flag names, or proprietary component selectors never leave your device. Open DevTools → Network and click Format to verify no requests are made.
How is this different from the Angular CLI ng format?
The Angular CLI does not ship a built-in formatter — there is no ng format command. Teams typically use Prettier with prettier-plugin-organize-imports and a pre-commit hook (Husky + lint-staged) for project-wide enforcement. This online tool is a fast alternative for one-off formatting when you do not have a configured Angular project on hand.