Code Tools

Tag Counter

All tools

Get an alphabetical count of every element type in a block of HTML.

How it works

Four simple steps

1

Paste HTML

Add a full page source or a template fragment.

2

Parsed like a browser

DOMParser builds the document, adding any implied elements.

3

Read the counts

Each tag name is listed alphabetically with its total.

4

Keep the inventory

Copy the list or download it as a text file.

Tag Counter

About Tag Counter

You want a quick inventory of a page: how many h1 tags it has, how many images, how deep the div soup goes, how many script tags a template pulls in. Counting by eye in the source is slow and easy to get wrong.

Paste HTML and the counter parses it with DOMParser, visits every element in the resulting document and lists each tag name with its total, sorted alphabetically (for example div: 42, h1: 1, img: 9). Counts update as you type, and the list can be copied or saved as a text file for an audit note.

Because the browser's parser does the work, its corrections are included. A fragment always reports html: 1, head: 1 and body: 1 even if you did not paste those tags, and elements the parser inserts, such as tbody inside a table, are counted too. The numbers therefore reflect the document the browser actually builds, which is usually what matters for SEO and performance checks. To see the markup behind a number, pull those elements out with the selector-based extractor, or view their nesting in the DOM tree outline. For the head of the page, you can also audit the page's meta tags.

The count is computed on a parsed document that never runs scripts, and the source stays in your browser.

Keyboard shortcut

Ctrl Enter - Run tool
FAQ

Frequently asked questions

See all FAQs

Answers for this tool. For site-wide help, open the FAQ hub.

The browser's parser always creates html, head and body, and inserts some required elements such as tbody in tables. They are counted because they exist in the parsed document.

No. Only elements are counted. Comments, text nodes and the doctype are ignored.

Yes. Any element the parser creates is included, so web components like my-card and inline SVG shapes like path or circle appear under their own names.

View more FAQs

Related tools

View all

HTML Formatter

Beautify and indent HTML markup.

Open

CSS Formatter

Format and pretty-print CSS.

Open

JS Formatter

Beautify JavaScript code.

Open

JSON Formatter

Beautify and validate JSON.

Open

Explore 321 free tools

Everything you need as a developer, marketer or creator - in one beautiful place.

Browse all tools