Skip to content

Angular Formatter

Format Angular component templates with this Angular Formatter. Paste template HTML with structural directives, bindings and interpolation and the tool places block elements such as div, section, p, ul and table on their own lines with two space indentation, collapses stray whitespace and formats inline script and style blocks. Directives, bindings and expressions stay exactly as written, so Angular developers get clean templates fast.

Reset

Frequently asked questions

What can I format with the Angular Formatter?

It formats Angular component templates, the HTML you write in .component.html files or in a template string. TypeScript component classes are not handled here; use the TypeScript Formatter for them.

Are directives and bindings preserved?

Yes, attributes such as *ngIf, *ngFor, [value], (click) and [(ngModel)] and interpolations such as {{ user.name }} are copied exactly as written. Only the whitespace between elements changes.

Which elements get their own lines?

When an element contains block level children, such as div, section, article, header, footer, nav, main, form, p, h1 to h6, ul, ol or table, each child goes on its own indented line. Elements without such children stay on one line with runs of whitespace collapsed to single spaces.

Why does my custom component stay on one line?

Custom elements such as app-root or mat-card are not block level HTML elements, so their content is kept inline unless it contains a block element like div or p. Wrap the content in a block element if you want it expanded.

Are list items placed on separate lines?

Not on their own: li is not one of the block level tags, so a ul whose only children are li elements stays on one line. Put block content such as a div inside the items to spread them out.

What happens with script and style tags?

Inline style blocks are formatted as CSS and inline scripts as JavaScript, indented under their tag. Content of pre and textarea elements is kept exactly as written.

Are HTML comments kept?

Yes, HTML comments are preserved and placed on their own line inside expanded elements. Their content is copied exactly, so commented out markup stays as it was.

Does it validate my template?

No, it does not compile or check the template, and unclosed tags are formatted as well as possible. Use ng build or your editor's Angular language service to find template errors.

Why is the output fenced as html?

Angular templates are HTML, so the result comes back as a Markdown code block marked html. Copy the lines between the fences into your template file.

How large can my template be?

Up to 5 MB per run, and larger input is rejected with a message. The output is identical to the Angular option of the Code Formatter.

About OneClick Pro

OneClick Pro is a free collection of more than 150 web tools for everyday work: converting images and units, formatting and validating code, checking domains and SEO, and working with text, dates and numbers. Every tool runs without registration or subscription, and what you enter is only used to calculate your result and is never stored. Use it as a quick toolbox for one-off tasks, or bookmark the tools you rely on every day.