How to Fix a Low Content-to-Code Ratio on Your Website
A low content-to-code ratio means most of a page's HTML is markup, styles, scripts and data, with very little readable text. By the end of this guide you will have measured the ratio on your weakest templates, moved inline code out of the HTML, trimmed repeated boilerplate, added useful text to thin pages, and re-checked the share of pages that fail.

Why it matters
Content-to-code ratio is not a direct Google ranking factor, but it is a reliable sign of two real problems: heavy HTML that slows download, parsing and Largest Contentful Paint, and thin pages with little for search engines or AI answer engines to quote. Crawlers and LLM-based fetchers often truncate or deprioritize very large documents, so a 600 KB page with 2 KB of text risks having its main content cut off or ignored. Leaner HTML with more substantive text is faster for users and easier to understand and cite.
What you need
Step-by-step fix
Measure the ratio and find the worst templates
The audit compares the visible text on each page with the size of the raw HTML, then reports what share of your pages fall below the acceptable ratio. Fix templates, not individual URLs: one bloated category template can fail hundreds of pages. Open a page from each template, paste the snippet below into the DevTools Console, and note the percentage, the text length and the HTML size.
Anything under roughly 10% deserves attention. Pages under 5% are the priority.
fetch(location.href).then(r=>r.text()).then(html=>{const d=new DOMParser().parseFromString(html,'text/html');d.querySelectorAll('script,style,noscript,svg,template,iframe').forEach(e=>e.remove());const text=d.body.textContent.replace(/\s+/g,' ').trim();console.log('Ratio: '+(text.length/html.length*100).toFixed(1)+'%','| text chars:',text.length,'| HTML bytes:',html.length);});Move inline CSS and JavaScript to external files
"` attributes all count as code in the HTML. Move them into cached external files that load once per visit, not once per page. Keep inline only the small critical CSS you truly need for above-the-fold rendering, ideally under about 10-15 KB.
Look for analytics, chat widgets and A/B testing snippets pasted into the header. Many of these can load as one external file with defer.
<!-- Before --> <style>/* 40 KB of theme CSS */</style> <script>/* 25 KB of slider + menu logic */</script> <!-- After --> <link rel="stylesheet" href="/assets/css/site.min.css"> <script src="/assets/js/site.min.js" defer></script>
Replace repeated inline SVGs and base64 images
;base64 strings, can add tens or hundreds of kilobytes to every page. Put the icons in one cached SVG sprite file and reference each icon with <use>. You can also load decorative icons as <img>`.
Swap any base64 image larger than about 2 KB for a normal image file.
<!-- One cached sprite file: /assets/icons.svg contains <symbol id="icon-cart">...</symbol> --> <svg class="icon" aria-hidden="true" width="20" height="20"><use href="/assets/icons.svg#icon-cart"></use></svg> <!-- Decorative icon as an image instead of inline markup --> <img src="/assets/icons/truck.svg" alt="" width="20" height="20">
Trim embedded JSON and hydration data
JavaScript frameworks and some themes embed page data as JSON in the HTML. __next_f payload, Nuxt's __NUXT__`, and Shopify product JSON. If a template passes a whole product catalog or full CMS records when it renders only a title and price, the HTML grows dramatically.
Pass only the fields the page actually renders. Paginate or lazy-load long lists, and remove unused data-* attributes holding serialized objects.
// Next.js (Pages Router) - pass only what the page renders
export async function getStaticProps() {
const products = await getProducts();
return {
props: {
products: products.slice(0, 24).map(p => ({ id: p.id, name: p.name, price: p.price, url: p.url, image: p.image }))
}
};
}Cut boilerplate from shared templates
Headers, mega menus, footers, cookie banners and hidden modals repeat on every page and often outweigh the main content. Review each one:
- Collapse mega menus with hundreds of links into category hubs, or a menu that loads on interaction.
- Remove hidden modals, quick-view popups and duplicate mobile/desktop menus that render the same links twice.
- Delete HTML comments, empty wrapper
<div>s and disabled sections left behind by page builders. - Enable HTML minification at your host, CDN or build step.
Add meaningful text to thin pages
Shrinking code only fixes half of the ratio. Pages that say almost nothing still fail. Give each thin template genuinely useful text:
- Category pages: a 150-300 word intro covering what is in the range and how to choose.
- Product pages: original descriptions, specs and sizing, not manufacturer copy.
- Landing pages: real answers to customer questions.
If a page has no reason to carry text, such as tag archives, filter combinations or empty search results, consider consolidating it, setting it to noindex, or removing it.
<section class="category-intro"> <h1>Running Shoes</h1> <p>Example Co stocks road, trail and track running shoes from 40 brands. Choose road shoes for pavement, trail shoes with deeper lugs for mud and rock, and lightweight flats for racing...</p> </section>
Re-measure and re-run the audit
Clear your page cache and CDN cache, then repeat the console measurement from step 1 on one URL per template. Confirm each ratio has risen above roughly 10%, and that the raw HTML size has dropped. Then re-run the site audit to check that the share of failing pages has fallen.
Recheck after theme updates or new apps and plugins, because they often reintroduce inline code.
curl -s -o page.html -w "HTML bytes: %{size_download}\n" https://example.com/category/shoesPlatform-specific notes
WordPress
Block themes inline global styles and per-block CSS by default, and page builders add many wrapper divs. In Elementor, go to Elementor > Settings > Features and enable 'Optimized DOM Output' and 'Improved CSS Loading' where available. Use a plugin such as Asset CleanUp or Perfmatters to unload scripts on pages that don't need them. Use your cache plugin's 'Minify HTML' option. Avoid 'Inline all CSS' settings, which lower the ratio.
Shopify
Edit in Online Store > Themes > ... > Edit code. Check theme.liquid and the snippets for inline SVG icons, and move them to an asset referenced with {{ 'icons.svg' | asset_url }}. Review installed apps, which inject script and style blocks. Uninstalling an app does not always remove its leftover code from the theme. Limit product JSON on collection templates.
Next.js
In the Pages Router, check the size of the __NEXT_DATA__ script. In the App Router, check the self.__next_f payload. Both grow with every prop passed to client components. Keep heavy data in Server Components and pass only serializable fields you render. Use next/image instead of base64 placeholders larger than a few hundred bytes.
Webflow
Enable Site settings > Publishing > Advanced publishing options > Minify HTML, CSS and JS. Move custom code from page-level embeds into Site settings > Custom code. Use external files hosted on your CDN where possible. Replace large Embed elements containing inline SVG with image assets.
Wix / Squarespace
Platform markup cannot be edited directly, so focus on what you control. Remove unused apps and embedded code blocks, avoid duplicate mobile-only sections, and add substantive text to thin pages.
Check that it worked
✅ How to verify
- Run the console snippet from step 1 on one URL per template and confirm each ratio is now around 10% or higher.
- Compare raw HTML size before and after with curl or the DevTools Network tab (Doc filter, 'Size' column). Look for a clear reduction.
- Use Google Search Console URL Inspection > View crawled page > HTML to confirm that Googlebot sees the added text in the server-rendered source.
- Re-run the site audit and check that the number of pages flagged for content-to-code ratio has dropped.
⚠️ Common mistakes
- Padding pages with filler text or hidden text to raise the ratio. This hurts quality and can violate Google's spam policies.
- Inlining all CSS for speed scores, which bloats every HTML document and lowers the ratio site-wide.
- Fixing a single URL instead of the shared template, so hundreds of similar pages still fail.
- Adding the new text with client-side JavaScript, so it is missing from the raw HTML that the audit and many crawlers read.
Is this still an issue on your site? Run a free audit — ZORO checks this and 294 other SEO, AI-visibility, accessibility and security signals, with fixes for your platform.
Check my site freeFAQ
What is a good content-to-code ratio?
There is no official standard. Most audit tools treat roughly 10-25% visible text as healthy and flag pages below about 10%. Use it as a diagnostic rather than a target: fast, useful pages matter more than an exact percentage.
Is content-to-code ratio a Google ranking factor?
Not directly. Google has said it does not use text-to-HTML ratio. The underlying causes do affect results, though: bloated HTML slows Core Web Vitals, and thin content offers little to rank for or be cited in AI answers.
Does minifying HTML improve the ratio?
Yes, slightly, because whitespace and comments count as code. The big gains come from removing inline CSS, JavaScript, SVG, base64 images and oversized JSON payloads, and from adding real text.
Should I remove JSON-LD structured data to improve the ratio?
No. Structured data is usually only a few kilobytes and helps search engines understand the page. Just make sure it describes visible content, rather than embedding entire catalogs or every review.
How to Fix Low-Quality AI-Generated Content on Your Site
How to Fix Duplicate Manufacturer Product Descriptions
How to Fix Decaying Traffic Pages Using Search Console Data
How to Fix Low Multimedia Richness on Content Pages
How to Fix Zero-Traffic Pages With No Google Impressions
How to Fix Outdated Statistics, Years and Prices on Your Site