Open the source of almost any production page and you get the same unfriendly sight: a single compressed line of markup that scrolls sideways forever, no indentation, no comments, nothing to show where one element ends and the next begins. The page renders beautifully; its source seems designed for machines only, and in a sense it is: minified HTML, built for transfer, not for people.

You do not have to read it in that form. The free HTML Formatter on Ovatly turns the one-liner back into an indented document you can work through like an outline. This guide covers the workflow end to end: take source from a page, format it, read the tree, plus the reverse trip, because the same tool minifies when you are the one shipping the page.

Contents

  • Quick answer
  • Why page source looks the way it does
  • The reading workflow: copy, format, read
  • How to format HTML, step by step
  • Worked example: from one line to a readable tree
  • How to read the formatted tree
  • The return trip: minifying when you ship
  • Limitations and alternatives
  • Common mistakes
  • FAQs
  • Conclusion

Quick answer

Copy the minified markup out of the page source, paste it into the HTML Formatter, choose an indent of 2 or 4 spaces, and press Format HTML. The markup comes back re-indented with its nesting visible, ready to copy or download. Then read from the top down: the least-indented lines are the outer structure, and each deeper level is one more layer of nesting. Formatting changes indentation only and runs in your browser, so the copy is yours to trim and keep.

Why page source looks the way it does

Production markup is usually minified before it is served. Minifying removes comments and the whitespace between tags, shrinking the file to close to a single line. Nothing about that is sinister: the browser needs the tags and content, not the indentation, and smaller files travel faster.

The cost lands on anyone who opens view-source with a practical question. Which element wraps this section? Where does this container end? Is this block inside the header or after it? In a one-line file, each question means counting tags by eye in a stream of text with no landmarks. Reading minified source directly is possible in the way reading a book with no paragraphs is possible: nothing stops you, and everything slows you down.

One part of a minified file keeps its shape. The content of pre, textarea, script and style blocks is left untouched when minifying, because whitespace there can be meaningful: preformatted text would collapse, and code could break. A normally spaced block in a compressed file is protection, not an oversight.

The reading workflow: copy, format, read

The workflow has three steps and one rule. Copy the portion of source you actually need rather than the entire document when the page is huge; the section you care about is usually a fraction of it. Format that copy. Then read the formatted version, keeping the rule in mind: it is a copy, so nothing you do to it affects the live page.

Working on a copy is what makes source reading useful. You can delete parts of the tree you have ruled out, paste a section next to your own markup to compare structures, or keep the formatted file as a reference while you edit. Download the result as a text file to keep it, because the work happens in your browser and disappears with the tab. Very large documents are fine to paste, but formatting happens on your device, so a huge file may take a moment; trimming first keeps it fast.

How to format HTML, step by step

  1. Open the HTML Formatter and paste your HTML into the input box.
  2. Choose an indent size of 2 or 4 spaces if you plan to format. Match the convention your project already uses.
  3. Press Format HTML to beautify the markup, or Minify HTML to compress it.
  4. Copy the result, or download it as a text file.

Worked example: from one line to a readable tree

Here is a small fragment as page source gives it:

<section><h2>Delivery options</h2><p>Choose at checkout.</p><ul><li>Standard</li><li>Express</li></ul></section>

Everything is present and correct, and almost nothing about the structure is visible. Paste it in, choose a 2-space indent and press Format HTML, and the same markup returns as:

<section>
  <h2>Delivery options</h2>
  <p>Choose at checkout.</p>
  <ul>
    <li>Standard</li>
    <li>Express</li>
  </ul>
</section>

No tag, attribute or word changed. What the second version gives you is a map: the section wraps three children, the list holds two items, and the heading and paragraph are siblings, not parent and child. Scale that up to a real page with hundreds of elements and the formatted version is the difference between reading and guessing.

How to read the formatted tree

Start at the margin. Lines at the lowest indent level are the skeleton of the page or fragment: the major sections in order. Read those first, top to bottom, and you have the outline of the whole structure before looking at any detail.

Then descend one level at a time. Pick the section you care about and read its children, noting what each one is. Indentation does the bookkeeping: anything indented further belongs to the element above it, and a return to a shallower level means that element has closed. Questions that were painful in the one-line version, like whether a block sits inside the header or after it, answer themselves by where the block's first line sits.

Two habits make reading faster. First, skim opening tags only on the first pass, since the tag name and attributes tell you what each block is, and read text content only when you reach the block you came for. Second, when a section surprises you, count levels rather than tags: a block sitting one level deeper than expected is nested inside something unexpected, and the element above it at the shallower level is its parent, named right there on the page.

The return trip: minifying when you ship

Reading is only half of the pair. When the markup is yours and the page is finished, the same tool runs the workflow backwards: press Minify HTML and it removes comments and the whitespace between tags, producing the compact form you would serve. The protected interiors still apply, so the content of pre, textarea, script and style blocks survives untouched. Keep the direction straight: format to read, review and edit; minify a copy to ship. The formatted file is your working source, comments and all, and the minified file is an output you can regenerate whenever you need it.

Limitations and alternatives

Formatting fixes indentation only. It does not repair invalid HTML, close missing tags or validate your markup, so if the source you copied is genuinely broken, the formatted output may still be messy and a validator is the tool that can say why. Indentation changes do not affect rendering in normal HTML, but minifying removes whitespace between tags, which can very occasionally matter for inline elements separated by a space; check pages relying on exact inline spacing after minifying. For live questions about a page's behaviour, the browser's developer tools inspect the running document, complementing a formatted copy.

Common mistakes

  • Reading the one-line source directly. Ten seconds of formatting saves an hour of squinting.
  • Copying the entire document when you need one section. Paste the fragment; huge files are slower to format and harder to search.
  • Assuming a spaced block in minified source is an error. It is the pre, textarea, script and style protection doing its job.
  • Editing the live page in your head. You formatted a copy; changes belong in your real source files.
  • Minifying your only readable copy. Keep the formatted version as the source; generate minified output when you ship.

FAQs

How do I read HTML that is all on one line? Copy it, paste it into the HTML Formatter, choose an indent of 2 or 4 spaces and press Format HTML. The markup comes back re-indented so the nesting is visible, and you can read it as a tree from the outermost element down.

Does formatting the source change the page? No. You are formatting a copy of the markup in your browser, not the live page. Formatting changes indentation only; tags, attributes, text and element order stay as they were.

Which indent size should I pick for reading? Either works for reading. Choose 2 or 4 spaces, matching the convention of the project the markup belongs to if you plan to keep or edit the formatted copy.

Why does part of the minified source still have spaces and line breaks? The content of pre, textarea, script and style blocks is left untouched when minifying, because whitespace inside those elements can be meaningful. Those blocks keep their internal spacing even in a minified file.

Is the page source I paste uploaded anywhere? No. Formatting and minifying run entirely in your browser, so the markup you paste stays on your device.

Conclusion

Minified source is a shipping format, not a reading format, and you never have to read it on its own terms. Copy the section, format it with the HTML Formatter, and read the tree from the margin down. When the markup is your own, the companion guide on common HTML formatting mistakes that hide real bugs covers the debugging traps, and the rest of the series lives in the Developer Tools guides archive.