# angular-html-parser

> A HTML parser extracted from Angular with some modifications

Latest version **10.12.0** (published 2026-09-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install angular-html-parser
pnpm add angular-html-parser
yarn add angular-html-parser
bun add angular-html-parser
```

## Health

**Score 65/100 (B)** — status: active.

Positive: esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 10.12.0 |
| Published | 2026-09-10 |
| First published | 2018-10-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Node | >= 14 |
| Dependencies | 0 |
| Unpacked size | 189.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 45 |
| Author | Ika |
| Maintainers | thorn0, fisker, ikatyang, sosukesuzuki |

## Links

- npm: https://www.npmjs.com/package/angular-html-parser
- Repository: https://github.com/prettier/angular-html-parser
- Homepage: https://github.com/prettier/angular-html-parser/blob/HEAD/packages/angular-html-parser#readme
- Issues: https://github.com/prettier/angular-html-parser/issues
- npm.io page: https://npm.io/package/angular-html-parser

## Recent versions

- 10.12.0 (latest) — 2026-09-10
- 10.11.0 — 2026-07-08
- 10.10.0 — 2026-06-25
- 10.9.0 — 2026-06-23
- 10.8.0 — 2026-06-22
- 10.7.0 — 2026-06-03
- 10.6.1 — 2026-05-19
- 10.6.0 — 2026-05-19
- 10.5.0 — 2026-04-10
- 10.4.0 — 2026-01-15
- 10.3.0 — 2026-01-09
- 10.2.1 — 2025-12-16
- 10.1.1 — 2025-11-21
- 10.1.0 — 2025-11-21
- 10.0.0 — 2025-10-11
- … 35 more at https://npm.io/package/angular-html-parser/versions

## README

# angular-html-parser

[![npm](https://img.shields.io/npm/v/angular-html-parser.svg)](https://www.npmjs.com/package/angular-html-parser)

An HTML parser extracted from Angular with some [modifications](#modifications)

[Changelog](https://github.com/prettier/angular-html-parser/blob/master/packages/angular-html-parser/CHANGELOG.md)

## Diff from upstream

[Link](https://github.com/prettier/angular-html-parser/compare/main...prettier:angular-html-parser:dev)

> [!TIP]
> Try sync `main` and `dev` branch with upstream first

## Install

```sh
# using npm
npm install --save angular-html-parser

# using yarn
yarn add angular-html-parser
```

## Usage

```js
import { parse } from "angular-html-parser";

const { rootNodes, errors } = parse(`
<!DOCTYPE html>
<html>
  <head>
    <title>Hello world!</title>
  </head>
  <body>
    <div>Hello world!</div>
  </body>
</html>
`);
```

## API

```ts
declare function parse(input: string, options?: Options): ng.ParseTreeResult;

interface Options {
  /**
   * any element can self close
   *
   * defaults to false
   */
  canSelfClose?: boolean;
  /**
   * support [`htm`](https://github.com/developit/htm) component closing tags (`<//>`)
   *
   * defaults to false
   */
  allowHtmComponentClosingTags?: boolean;
  /**
   * do not lowercase tag names before querying their tag definitions
   *
   * defaults to false
   */
  isTagNameCaseSensitive?: boolean;
  /**
   * customize tag content type
   *
   * defaults to the content type defined in the HTML spec
   */
  getTagContentType?: (
    tagName: string,
    prefix: string,
    hasParent: boolean,
    attrs: Array<{ prefix: string; name: string; value?: string | undefined }>,
  ) => void | ng.TagContentType;
  /**
   * tokenize angular control flow block syntax
   */
  tokenizeAngularBlocks?: boolean;
  /**
   * tokenize angular let declaration syntax
   */
  tokenizeAngularLetDeclaration?: boolean;
}
```

## Modifications

- add `CDATA` node
- add `DocType` node
- add `nameSpan` field to `Element` and `Attribute`
- allow case-insensitive closing tags for non-foreign elements
- fix `Comment#sourceSpan`
- support [bogus comments](https://www.w3.org/TR/html5/syntax.html#bogus-comment-state) (`<!...>`, `<?...>`)
- ~~support full [named entities](https://html.spec.whatwg.org/multipage/entities.json)~~ (fixed upstream)
- add `type` property to nodes
- value span for attributes includes quotes

## Development

```sh
# build
yarn run build

# test
yarn run test
```

## License

MIT © [Ika](https://github.com/ikatyang)

---
_Source: https://npm.io/package/angular-html-parser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
