Code to Text Ratio: What It Tells You and How to Check It
Measure visible text against markup, inline scripts and CSS, find hidden text and boilerplate, and compare templates, without chasing a magic ratio.

Code to Text Ratio: What It Tells You and How to Check It
The code to text ratio, also called the text to HTML ratio, compares the readable words on a page with the size of its HTML. SEO tools have reported it for years, and many people still believe a higher ratio ranks better. It does not: Google has said it does not use the measure. So why check it at all? Because the things that push the ratio down, bloated templates, huge inline scripts and thin pages, do matter for speed and quality.
What makes up a page
A page's HTML holds more than text. There are the tags and attributes that structure it, inline scripts such as analytics snippets and the data blobs many frameworks embed to restore state, structured data in JSON-LD, inline CSS in style tags and attributes, comments left by developers, and sometimes text that is hidden from visitors. Breaking the page into these parts shows where the bytes go.
Running a check
Paste the page source into the Code to Text Ratio Checker. The tool shows the share of visible text, the total size and the number of visible words, and draws a bar with each part in its own colour. It separates main content inside main or article elements from boilerplate in headers, menus, sidebars and footers, and counts screen-reader-only text separately because it serves assistive technology.
To compare templates, add several pages, either one at a time or by opening several HTML files at once. The compare view lists size, text share, words, inline JavaScript, inline CSS, hidden words and main content share for each page, so the odd one out stands out.
What to do with the results
If inline scripts dominate, look at what is embedded. Frameworks that serialise the entire data store into the page can often send less, or load it later. Analytics and tag snippets belong in external files that browsers can cache.
If markup dominates, the templates may be nesting wrappers deeply or repeating large blocks such as mega menus on every page. Reducing them helps both size and rendering speed.
If the main content share is low, menus and footers outweigh the article. That is common on short pages, and the real fix is often more useful content, not fewer links.
If the word count is low on a page that is meant to answer a question, it may be thin. Add substance that helps the reader rather than padding.
Hidden text
The checker lists text inside elements with the hidden attribute or styles that hide it, such as display none, visibility hidden, a zero font size or a large negative text indent, and shows samples. Hidden text is not automatically a problem. Tabs, accordions and mobile menus hide text that visitors can open. Text that no visitor can ever see, such as keyword lists hidden for search engines, breaks Google's spam policies and should be removed.
Keep it in proportion
Use the ratio as a pointer, not a target. Compare similar pages on your own site, investigate outliers, and fix the real causes: slow templates, unnecessary inline code, hidden spam and thin content. A page that is fast, clear and useful will have a sensible ratio as a side effect, whatever the exact number turns out to be.
Using it in a site audit
In a full audit, check one page from each template rather than every URL. A blog post, a category page, a product page and the home page usually cover most of the site. If one template has far more inline code or hidden text than the others, fix it once and every page built from it improves.



