Code-to-Text Ratio: Useful SEO Signal or Just an SEO Myth?
Code-to-text ratio is not a ranking factor, but a very low ratio can reveal bloated HTML or thin content. Here is how to use it as a diagnostic, not a goal.

Code-to-text ratio is not a confirmed Google ranking factor, so chasing a particular percentage is an SEO myth. It is still a useful diagnostic signal: a very low ratio often points to real problems such as bloated HTML, heavy inline scripts and styles, or pages with too little visible content. Use it to find pages worth investigating, then fix the underlying issue rather than the number.
Key takeaways
- The ratio compares visible text to the total size of a page's HTML source.
- Google has never confirmed it as a ranking signal, and there is no "correct" percentage.
- A low ratio is a prompt to look for page bloat or thin content, not a problem in itself.
- Fix causes: move inline code to cached files, trim markup, and add genuinely useful content where pages are thin.
- Never pad pages with filler text just to raise the ratio.
What code-to-text ratio measures
The calculation is simple. A tool downloads the page's HTML, strips out tags, scripts and styles to get the visible text, then divides the text size by the total HTML size:
code-to-text ratio = (size of visible text / size of full HTML) x 100
Example:
Full HTML document: 120 KB
Visible text content: 9 KB
Ratio: 7.5%
Two details are easy to miss. First, most tools measure only the HTML document itself, not external CSS, JavaScript or images, so a page with huge external scripts can still show a decent ratio. Second, tools differ in how they extract text, so the same page can score differently in different checkers. Compare pages using the same tool, not numbers across tools.
You can check any URL with a Code to Text Ratio Checker to get the HTML size, text size and percentage in one go.
Is it a ranking factor?
There is no evidence that it is. Google has not listed code-to-text ratio in its documentation as something it uses, and Google representatives have repeatedly downplayed the idea over the years. Search engines are built to parse modern pages that include large amounts of markup and script; they extract the main content and evaluate that.
The idea persists for understandable reasons. Pages with very low ratios often share other problems that do matter:
- Thin content: a few sentences surrounded by navigation, widgets and boilerplate.
- Heavy HTML: large documents that take longer to download and parse, especially on slow mobile connections.
- Template bloat: mega-menus, inline SVG icons and repeated tracking snippets on every page.
So the ratio correlates with problems without being the cause. That is exactly why it works as a diagnostic and fails as a target.
What a "good" ratio looks like
You will see thresholds quoted online, but they are rules of thumb invented by tool makers, not standards. The honest answer is that a normal ratio depends on the page type:
| Page type | Typical pattern | Should you worry? |
|---|---|---|
| Long-form article | Higher ratio, lots of text | Only if it is unexpectedly low compared with similar posts |
| Product page | Moderate; specs, reviews and scripts | Check if the description is a single sentence |
| Category or listing page | Lower; mostly links and product cards | Usually normal |
| App-like or JavaScript-heavy page | Very low in raw HTML | Check that content renders and is indexable |
| Home page | Varies widely | Rarely worth optimizing for the ratio |
The most useful comparison is internal: run several pages of the same type and look for outliers. If most of your blog posts sit in one range and three sit far below it, those three deserve a look.
How to investigate a low ratio
When a page stands out, open its raw HTML. Get Source Code of Webpage shows exactly what the server returns, which is what the ratio was calculated from. Then look for the usual suspects:
- Large inline style blocks. Page builders and some themes print hundreds of lines of CSS inside
<style>tags on every page. - Inline scripts and JSON. Framework state objects, tracking code and chat widgets can add a lot of bytes before any content appears.
- Inline SVG icons repeated in menus and footers.
- Deeply nested wrappers from visual builders, where each paragraph sits inside many
<div>elements with long class lists. - Base64-encoded images or fonts embedded directly in the HTML.
- Hidden content such as huge mega-menus or off-screen panels duplicated for mobile and desktop.
- Very little actual content: the page simply does not say much.
Fixes that help (and why)
Each fix below improves something real, and the ratio tends to improve as a side effect.
Move inline CSS and JavaScript to external files
External files can be cached by the browser and reused across pages, so visitors download them once instead of with every HTML document. Keep small amounts of critical CSS inline if your performance setup relies on it; move the rest out.
Trim template markup
Remove unused widgets, simplify navigation, and replace repeated inline SVGs with a sprite or icon font where practical. Smaller HTML documents download and parse faster, which can help metrics like Largest Contentful Paint on slower connections.
Enable compression
Gzip or Brotli compression does not change the ratio tools report, but it shrinks what actually travels over the network. Check that your server sends a header like this for HTML responses:
HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
Content-Encoding: br
Strengthen thin pages
If the page is low because it has little to say, the fix is better content: answer the questions visitors actually have, add specifics, examples or data you own. Alternatively, merge several thin pages into one stronger page and redirect the old URLs.
Check JavaScript-rendered content
Pages built entirely in the browser can show an extremely low ratio because the raw HTML is mostly an empty shell plus scripts. Google can render JavaScript, but rendering adds a step and can fail. Use the URL Inspection tool in Search Console to confirm the rendered page contains your content, and consider server-side rendering for important pages.
A worked example
Imagine a 900-word blog post on example.com built with a visual page builder. The checker reports a 4% ratio, while other posts on the same site sit around 15%. Viewing the source shows why: roughly 60 KB of inline CSS generated by the builder, a 25 KB inline JSON object for a slider plugin that is not even used on this post, and a mega-menu repeated twice for desktop and mobile.
The fixes are ordinary housekeeping: switch the builder to output CSS as a cached file, disable the slider plugin on pages that do not use it, and render one menu that adapts with CSS. The post's text did not change at all, yet the HTML document is much smaller and the ratio now looks like its siblings. The real benefit is a lighter page, not the number.
What not to do
- Do not pad pages with filler text. Extra words that do not help readers make the page worse, even if the percentage rises.
- Do not hide text to inflate the ratio. Hidden keyword text violates Google's spam policies.
- Do not strip useful markup such as structured data, accessibility attributes or meaningful headings to save bytes.
- Do not set a site-wide target and rewrite category or tool pages that are naturally link- or script-heavy.
Quick checklist
- Run your key templates through a ratio checker and note each page type's typical range.
- Flag outliers well below the norm for their type.
- View the raw source and identify what is taking up the space.
- Move inline CSS and JavaScript to cached files and remove unused widgets.
- Confirm compression is enabled for HTML.
- Improve or consolidate pages that are genuinely thin.
- Re-measure, but judge success by speed, engagement and rankings, not the percentage.