What is the code to text ratio?
The code to text ratio is the share of a web page's bytes that remain when the markup is stripped away. Paste the source of a page and this tool removes comments, script blocks, style blocks, tags, attributes and HTML entities, measures what is left in bytes, and reports it as a percentage of the whole document. The text that was counted is shown underneath, so the figure can be checked against what it claims to measure.
The number exists because the two things grow at different rates. Text grows with what an author writes, while markup grows with how the page is built: a framework's wrappers, a long inline style block, a bundled script and a nest of containers all add bytes without adding a single word a reader can use. A page that is 4% text is therefore normal for an application shell and worrying for an article, and the same figure can mean opposite things depending on what the page is for.
Modern crawlers execute JavaScript and reason about layout, so the ratio is not the ranking factor it was once assumed to be. What it remains is a fast, honest way to notice that content is missing from the source: a product page whose description never made it into the HTML, a blog post whose body arrives only after a script runs, or a template that has quietly stopped rendering its main text. For that job it is still worth the thirty seconds.
How to check a page's code to text ratio
- Open the page you want to measure and view its source — the server's HTML, not the live DOM after scripts have run.
- Copy the source, or just the region you care about, and paste it into the box.
- Read the ratio, and the byte counts for visible text, code and the document as a whole.
- Check the extracted text underneath: if a section you expected is missing, it was inside a script or a template.
- Copy the figures, or clear the box and measure a second page for comparison.
- Where the ratio is very low, use the extracted text to decide whether content is genuinely absent rather than simply hidden.
Code to Text Ratio Checker limits and rules
| Item | Limit |
|---|---|
| Input | Raw HTML source, or a fragment of it; a full document gives the more meaningful figure |
| Counted as text | Characters outside tags, comments, script blocks and style blocks, with entities removed |
| Counted as code | Tags, attributes, comments, script and style blocks, and HTML entities |
| Measure | UTF-8 bytes, so multi-byte characters count more than one |
| Scripts | JavaScript is not executed, so content injected at runtime is not seen |
| Output | The ratio, three byte counts, a plain-language verdict and the extracted text |
| Not covered | Fetching a URL, rendering a page, or judging whether the text is any good |
When to use it
- Checking whether a page's main content is present in the server's HTML.
- Comparing a template-driven page against a hand-written one.
- Noticing that a framework has wrapped a short article in a large amount of markup.
- Confirming that the text extracted from a page reads as expected.
- Measuring a fragment such as an article body rather than a whole document.
Is it private?
Everything is measured in this page with a single pass over the text you paste. No URL is fetched, no page is rendered, and nothing is uploaded, stored or logged.
Frequently asked questions
There is no single good figure, which is why the verdict here is phrased rather than scored. A conventional content page commonly lands between about 25% and 70% text, an application shell or a JavaScript-rendered page is often well under 10%, and a plain article with little around it can exceed 80%. What matters is whether the figure matches the page's job — a low ratio on an article means content is missing, while a low ratio on a dashboard is entirely expected.
Most often because the text is not in the HTML you pasted. A page built with a client-side framework ships a small shell and a large bundle, and the words arrive after the script runs, so the source really does contain very little text while the rendered page contains plenty. The extracted text box makes that visible immediately: if the body is missing from it, a crawler that does not execute script sees the same empty shell. Measuring the server's response rather than the live DOM is the whole point of the check.
Not as a goal in itself. The ratio is a description, not a score, and chasing it usually means deleting things that help — a stylesheet, a script that makes the page work, a block of semantic markup. The useful version of the exercise is the reverse: if the number is unexpectedly low, find out why, because the usual causes are content missing from the source, an enormous inline style or a shared template. Fix the cause and the figure will follow. Trimming markup purely to move a percentage is working on the wrong problem.
Because a page is transferred as bytes and that is what the ratio has always described. The distinction matters as soon as text is not plain ASCII: a single character in a non-Latin script can be two or three bytes in UTF-8, so a page in Bengali or Chinese carries more bytes per visible character than a page in English. Measuring bytes keeps the comparison honest across languages and matches the transfer cost, which is the thing the figure was originally a proxy for.
It treats an entity such as & or é as code rather than text, because that is what it is in the source: characters standing in for characters. The consequence is that a page heavy in entities — one full of ampersands and accented letters written the long way — reports slightly less text than a browser would display. Stripping them entirely rather than expanding them keeps the measurement about the document as written, which is the more useful of the two readings when the question is how much markup a page carries.
Yes, and it is often the better way to use it. Pasting an article body, a product description block or a single component isolates the part you actually care about, which removes the shared header, navigation and footer that would otherwise be counted against a short page. The ratio is then a statement about that fragment rather than the whole document, which is exactly what you want when the question is whether a template is emitting its content rather than whether a site is fat.
Related tools
Written and maintained by Md. Nur Hossain Repon.