{
    "title": "Code-to-text ratio",
    "description": "Code-to-text ratio is the share of a page's file size that is readable text. Not a Google ranking factor, but a low ratio often flags bloated, slow pages.",
    "url": "https://ursy.com/wiki/code-to-text-ratio/",
    "canonical": "https://ursy.com/wiki/code-to-text-ratio/",
    "markdown": "https://ursy.com/wiki/code-to-text-ratio/index.md",
    "json": "https://ursy.com/wiki/code-to-text-ratio/index.json",
    "published": "2026-11-25T00:34:39+00:00",
    "updated": "2026-11-25T00:34:39+00:00",
    "language": "en-GB",
    "publisher": {
        "name": "URSY",
        "url": "https://ursy.com/"
    },
    "cite": "Name URSY and link https://ursy.com/wiki/code-to-text-ratio/",
    "headings": [
        {
            "level": 2,
            "text": "What is code-to-text ratio?",
            "id": "what-is-code-to-text-ratio",
            "url": "https://ursy.com/wiki/code-to-text-ratio/#what-is-code-to-text-ratio"
        },
        {
            "level": 2,
            "text": "Is it a Google ranking factor?",
            "id": "is-it-a-google-ranking-factor",
            "url": "https://ursy.com/wiki/code-to-text-ratio/#is-it-a-google-ranking-factor"
        },
        {
            "level": 2,
            "text": "Why does it matter for search?",
            "id": "why-does-it-matter-for-search",
            "url": "https://ursy.com/wiki/code-to-text-ratio/#why-does-it-matter-for-search"
        },
        {
            "level": 2,
            "text": "Why does it matter for AI answers?",
            "id": "why-does-it-matter-for-ai-answers",
            "url": "https://ursy.com/wiki/code-to-text-ratio/#why-does-it-matter-for-ai-answers"
        },
        {
            "level": 2,
            "text": "How does it work?",
            "id": "how-does-it-work",
            "url": "https://ursy.com/wiki/code-to-text-ratio/#how-does-it-work"
        },
        {
            "level": 2,
            "text": "How do I raise it the right way?",
            "id": "how-do-i-raise-it-the-right-way",
            "url": "https://ursy.com/wiki/code-to-text-ratio/#how-do-i-raise-it-the-right-way"
        },
        {
            "level": 2,
            "text": "Does compression change the ratio?",
            "id": "does-compression-change-the-ratio",
            "url": "https://ursy.com/wiki/code-to-text-ratio/#does-compression-change-the-ratio"
        },
        {
            "level": 2,
            "text": "Common mistakes",
            "id": "common-mistakes",
            "url": "https://ursy.com/wiki/code-to-text-ratio/#common-mistakes"
        },
        {
            "level": 2,
            "text": "A worked example",
            "id": "a-worked-example",
            "url": "https://ursy.com/wiki/code-to-text-ratio/#a-worked-example"
        },
        {
            "level": 2,
            "text": "How to check it",
            "id": "how-to-check-it",
            "url": "https://ursy.com/wiki/code-to-text-ratio/#how-to-check-it"
        },
        {
            "level": 2,
            "text": "Questions",
            "id": "questions",
            "url": "https://ursy.com/wiki/code-to-text-ratio/#questions"
        },
        {
            "level": 3,
            "text": "What is a good code-to-text ratio?",
            "id": "what-is-a-good-code-to-text-ratio",
            "url": "https://ursy.com/wiki/code-to-text-ratio/#what-is-a-good-code-to-text-ratio"
        },
        {
            "level": 3,
            "text": "Will raising it lift my rankings?",
            "id": "will-raising-it-lift-my-rankings",
            "url": "https://ursy.com/wiki/code-to-text-ratio/#will-raising-it-lift-my-rankings"
        },
        {
            "level": 3,
            "text": "Does schema markup hurt the ratio?",
            "id": "does-schema-markup-hurt-the-ratio",
            "url": "https://ursy.com/wiki/code-to-text-ratio/#does-schema-markup-hurt-the-ratio"
        },
        {
            "level": 2,
            "text": "Related words",
            "id": "related-words",
            "url": "https://ursy.com/wiki/code-to-text-ratio/#related-words"
        },
        {
            "level": 2,
            "text": "Sources",
            "id": "sources",
            "url": "https://ursy.com/wiki/code-to-text-ratio/#sources"
        }
    ],
    "links": [
        {
            "text": "Google",
            "url": "https://ursy.com/wiki/google/",
            "internal": true
        },
        {
            "text": "HTML",
            "url": "https://ursy.com/wiki/html/",
            "internal": true
        },
        {
            "text": "CSS",
            "url": "https://ursy.com/wiki/css/",
            "internal": true
        },
        {
            "text": "SEO starter guide",
            "url": "https://developers.google.com/search/docs/fundamentals/seo-starter-guide",
            "internal": false
        },
        {
            "text": "ranking factor",
            "url": "https://ursy.com/wiki/ranking-factor/",
            "internal": true
        },
        {
            "text": "Googlebot documentation",
            "url": "https://developers.google.com/search/docs/crawling-indexing/googlebot",
            "internal": false
        },
        {
            "text": "Core Web Vitals",
            "url": "https://ursy.com/wiki/core-web-vitals/",
            "internal": true
        },
        {
            "text": "page speed",
            "url": "https://ursy.com/wiki/page-speed/",
            "internal": true
        },
        {
            "text": "thin content",
            "url": "https://ursy.com/wiki/thin-content/",
            "internal": true
        },
        {
            "text": "AI crawler",
            "url": "https://ursy.com/wiki/ai-crawler/",
            "internal": true
        },
        {
            "text": "client-side vs server-side rendering",
            "url": "https://ursy.com/wiki/client-side-vs-server-side-rendering/",
            "internal": true
        },
        {
            "text": "content chunking",
            "url": "https://ursy.com/wiki/content-chunking/",
            "internal": true
        },
        {
            "text": "retrieval-augmented generation",
            "url": "https://ursy.com/wiki/retrieval-augmented-generation/",
            "internal": true
        },
        {
            "text": "llms.txt",
            "url": "https://ursy.com/wiki/llms-txt/",
            "internal": true
        },
        {
            "text": "Markdown Version Checker",
            "url": "https://ursy.com/markdown-version-checker/",
            "internal": true
        },
        {
            "text": "JSON-LD",
            "url": "https://ursy.com/wiki/json-ld/",
            "internal": true
        },
        {
            "text": "schema markup",
            "url": "https://ursy.com/wiki/schema-markup/",
            "internal": true
        },
        {
            "text": "cookie banners",
            "url": "https://ursy.com/wiki/cookie-banner/",
            "internal": true
        },
        {
            "text": "minification entry",
            "url": "https://developer.mozilla.org/en-US/docs/Glossary/Minification",
            "internal": false
        },
        {
            "text": "minification",
            "url": "https://ursy.com/wiki/minification/",
            "internal": true
        },
        {
            "text": "async or defer",
            "url": "https://ursy.com/wiki/async-and-defer-scripts/",
            "internal": true
        },
        {
            "text": "Lighthouse DOM size audit",
            "url": "https://developer.chrome.com/docs/lighthouse/performance/dom-size",
            "internal": false
        },
        {
            "text": "keyword stuffing",
            "url": "https://ursy.com/wiki/keyword-stuffing/",
            "internal": true
        },
        {
            "text": "text compression",
            "url": "https://web.dev/articles/reduce-network-payloads-using-text-compression",
            "internal": false
        },
        {
            "text": "text compression",
            "url": "https://ursy.com/wiki/text-compression-gzip-and-brotli/",
            "internal": true
        },
        {
            "text": "hreflang",
            "url": "https://ursy.com/wiki/hreflang/",
            "internal": true
        },
        {
            "text": "canonical tag",
            "url": "https://ursy.com/wiki/canonical-tag/",
            "internal": true
        },
        {
            "text": "spam policies",
            "url": "https://developers.google.com/search/docs/essentials/spam-policies",
            "internal": false
        },
        {
            "text": "cloaking",
            "url": "https://ursy.com/wiki/cloaking/",
            "internal": true
        },
        {
            "text": "JavaScript SEO",
            "url": "https://ursy.com/wiki/javascript-seo/",
            "internal": true
        },
        {
            "text": "SEO Checker",
            "url": "https://ursy.com/seo-checker/",
            "internal": true
        },
        {
            "text": "SEO audit",
            "url": "https://ursy.com/seo-audit/",
            "internal": true
        },
        {
            "text": "JavaScript SEO Checker",
            "url": "https://ursy.com/javascript-seo-checker/",
            "internal": true
        },
        {
            "text": "HTTP Header Checker",
            "url": "https://ursy.com/http-header-checker/",
            "internal": true
        },
        {
            "text": "Page Speed Checker",
            "url": "https://ursy.com/page-speed-checker/",
            "internal": true
        },
        {
            "text": "Readability Checker",
            "url": "https://ursy.com/readability-checker/",
            "internal": true
        },
        {
            "text": "AI Readiness Checker",
            "url": "https://ursy.com/ai-readiness-checker/",
            "internal": true
        },
        {
            "text": "asset diet report",
            "url": "https://ursy.com/pro/asset-diet-report/",
            "internal": true
        },
        {
            "text": "JavaScript rendering check",
            "url": "https://ursy.com/pro/javascript-rendering-check/",
            "internal": true
        },
        {
            "text": "Word count",
            "url": "https://ursy.com/wiki/word-count/",
            "internal": true
        },
        {
            "text": "DOM",
            "url": "https://ursy.com/wiki/dom-document-object-model/",
            "internal": true
        },
        {
            "text": "Technical SEO",
            "url": "https://ursy.com/wiki/technical-seo/",
            "internal": true
        }
    ],
    "words": 1107,
    "text": "Code-to-text ratio is the share of a web page’s file size that is visible, readable text, compared with the HTML, CSS, JavaScript and markup around it. A page that weighs 200 KB with 10 KB of words has a ratio of about 5%. Google does not publish this number as a ranking signal, but a very low ratio often points to slow, bloated pages and thin words. What is code-to-text ratio? Open any page and view its source. You see the words a reader reads, wrapped in tags, scripts, style rules, tracking code and data. The ratio sets those two parts side by side. Some tools call it text-to-HTML ratio. There is no standard formula: most audit tools strip the tags from the HTML, count the bytes of text that remain and divide by the bytes of the whole document. Some count only the HTML file. Others add the CSS and scripts it loads. That is why two tools give two different figures for the same page. Is it a Google ranking factor? No official Google document lists it as one. Google’s SEO starter guide states that how long a page is makes no difference to ranking on its own, and that no ideal word count exists. A ratio is just word count divided by file size, so treat it as a symptom to look into, not a ranking factor to chase. A short product page with a clear price can be perfect at 3%. Why does it matter for search? The ratio is useful because of what usually sits behind a bad score: Crawl limits. Google’s Googlebot documentation sets a 2MB cap on each supported file it fetches, and that cap applies to the file before compression. Anything after that cut-off is not sent for indexing. A page stuffed with inline code can push its real words past the limit. Each file counts alone. The same page says every CSS and JavaScript file is fetched separately and has the same limit. Speed. More code means more to download, parse and run, which hurts Core Web Vitals and page speed. Thin pages. A template with a heavy menu, footer and pop-ups but two lines of copy is often thin content. Why does it matter for AI answers? An AI crawler wants the words. Text that only appears after scripts run can be missed by any crawler that does not run JavaScript; see client-side vs server-side rendering. Clean, text-first HTML is easier to split into passages, which helps content chunking and retrieval-augmented generation. Some sites also offer a plain copy of each page for machines, the idea behind llms.txt. Our Markdown Version Checker tests whether a page has one. How does it work? A simple version takes three steps: Download the HTML of the page and note its size in bytes. Remove every tag, script block, style block and comment, then collapse the white space. Divide the bytes of text left by the bytes of the full file and multiply by 100. The result swings with things that have nothing to do with quality: inline SVG icons, JSON-LD blocks for schema markup, cookie banners and page builder wrappers all add code. That is fine when the code does a job. How do I raise it the right way? Minify. MDN’s minification entry describes it as removing unnecessary or redundant data without changing how the browser processes the file, such as comments and white space. See minification. Move inline CSS and scripts to files. The browser can cache them, and they stop crowding the HTML. Load scripts with async or defer. Cut the DOM. Chrome’s Lighthouse DOM size audit warns when the body has more than about 800 nodes and flags an error above about 1,400. Remove dead plugins and tags. Every old tracking script adds weight. Add useful words, not filler. Answer the questions buyers ask. Padding to move a ratio is keyword stuffing by another name. Does compression change the ratio? Not the ratio itself, but it changes what travels over the wire. The web.dev article on text compression says gzip and Brotli work best on text files such as HTML, CSS and JavaScript, and that minification and compression add up. Google’s 2MB limit is on the uncompressed file, so compression helps speed but does not lift that limit. See text compression. Common mistakes Chasing a target. There is no official “good” figure. Compare pages of the same type on your own site. Deleting useful code. Structured data, hreflang tags and a canonical tag lower the ratio but earn their place. Hiding text. Adding text people cannot see breaks Google’s spam policies; see cloaking. Words only in scripts. If the text is built by JavaScript, the raw HTML ratio looks tiny and some crawlers see nothing. Read JavaScript SEO. A worked example One shop compares 3 page types: Page HTML size Text size Ratio What to do Blog guide 90 KB 18 KB 20% Fine Product page 240 KB 4 KB 1.7% Move 150 KB of inline script to a file Category page 2.4 MB 6 KB 0.25% Over Google’s 2MB crawl limit: cut inline SVG and data The category page is the urgent one. Its last products may never be indexed. How to check it Run the page through our SEO Checker or a full SEO audit to see size, headings and words together. Put the same address into our JavaScript SEO Checker: it shows which words exist before any script runs. Check the response headers and compression with our HTTP Header Checker, then time the load on our Page Speed Checker (coming soon). Test how easy the words are to read with our Readability Checker. Ask whether AI systems can read the text with our AI Readiness Checker. In URSY Pro, the asset diet report (Pro) lists the heaviest files, and the JavaScript rendering check (Pro) watches pages over time. Questions What is a good code-to-text ratio? There is no official number. Look for outliers: pages far below others of the same type. Will raising it lift my rankings? Not by itself. Faster pages and better answers can help; the ratio only points at them. Does schema markup hurt the ratio? It lowers the figure, but it gives machines facts. Keep it if it matches the page. Related words Minification Thin content Word count DOM Technical SEO Sources Google Search Central: Googlebot, checked 25 November 2026 Google Search Central: SEO starter guide, checked 25 November 2026 MDN Web Docs: Minification, checked 25 November 2026 Chrome for Developers: Avoid an excessive DOM size, checked 25 November 2026 Google Search Central: Spam policies for Google web search, checked 25 November 2026 web.dev: Reduce network payloads using text compression, checked 25 November 2026 Updated 25 November 2026 by URSY.",
    "source": "https://ursy.com/wiki/code-to-text-ratio/"
}