CardKit
Small tools for website editing and template work

BLOG

How to Clean Up Exported HTML Without a Code Editor

Somewhere between the website builder, the export folder and the new host, clean markup turns into one endless line of text full of comments and empty tags. You do not need a development environment to fix it - you need to know which dirt is safe to remove and which "dirt" is actually load-bearing.

The pain: the export works, but nobody can read it

Exported HTML arrives in a predictable state. Page builders and "view source" copies are often minified - the entire document on one line. Templates carry comment banners, tracking scripts and empty divs from sections that were deleted months ago. Old exports have inline styles on every paragraph. The page renders fine, which makes the problem easy to postpone, until one day you need to change a heading and cannot find it in forty thousand characters of wall-to-wall markup.

Most advice at this point is "open it in VS Code." Reasonable for developers; unreasonable for someone who runs a shop and edits two pages a month. The cleanup below needs nothing beyond a browser.

First: know what counts as junk

Cleaning goes wrong when safe-to-remove and load-bearing get mixed up. Sort everything you might remove into the right bucket first.

Safe to remove

  • HTML comments. <!-- ... --> never renders. Comment banners, leftover notes, builder artifacts - all removable.
  • Whitespace noise. Blank lines, indentation gone wild, runs of spaces. Pure formatting; the browser ignores all of it.
  • Empty elements. <div></div> pairs and empty paragraphs left behind by deleted content - if nothing targets them with CSS. Which leads to the other bucket.

Looks like junk, is not

  • Classes and IDs. They look random. They connect markup to the stylesheet and sometimes to scripts. Removing or renaming them is the number one self-inflicted template wound - the subject of Why Your HTML Template Falls Apart When You Edit It.
  • Data attributes. data-* attributes drive sliders, galleries, analytics and frameworks. Invisible, easy to dismiss, frequently essential.
  • Accessibility attributes. alt, aria-*, role. They look verbose. Deleting them quietly damages the page for screen reader users.
  • Nested structure. Redundant-looking divs often exist so a CSS rule somewhere can target "everything inside this." Flattening the nesting changes what those rules match.

The rule: clean formatting aggressively; clean structure almost never. Formatting is how the code is written down. Structure is what the code does.

The cleanup, step by step

Step 1: make it readable

Everything else depends on being able to see the markup. Paste the export into the HTML Cleaner and format it: every tag on its own line, nesting visible as indentation. A document that was one line becomes a scannable outline, and sections become findable with a simple text search.

Step 2: remove the comments

With the document readable, strip comments. This is pure profit: smaller file, nothing visual changes. Comment banners that name sections (<!-- START HERO --> and friends) can be worth keeping if you rely on them for navigation, but builder artifacts and old notes can go.

Step 3: check the result still has the same bones

One verification habit separates safe cleaning from accidental damage: confirm the element count is unchanged. If the document had 214 div tags before cleanup and 214 after, you removed only formatting. If the number moved, something structural got caught in the removal - undo and be more surgical. The HTML Cleaner is built to leave structure untouched, but the check is free and catches paste-in-transit accidents too.

Step 4: only now, edit the content

With a formatted, comment-free document, the actual job - replacing a heading, swapping an image URL - is quick. Do content edits after cleanup, so you never confuse the two kinds of change. If you prefer editing by clicking rather than by reading markup, the CSS Code Editor renders the section and lets you edit it visually.

Step 5: keep the original

Save the untouched export as page-original.html and work on a copy. Cleanup is the moment when a backup earns its keep, because it is the step where a wrong click is most likely.

Minify or not?

After cleaning, some people run the file back through a minifier to save kilobytes. For hand-edited small pages, this trades a real cost - the file becomes unreadable again, so the next edit starts from scratch - for a saving measured in milliseconds. Keep the working copy readable. If a page is genuinely heavy, removing unused images and scripts saves far more than whitespace does.

Real scenarios

The migrated website. A four-page site left a dying builder as a zip of exports, every page one line of markup with tracker comments throughout. Formatted and comment-stripped, each page landed around 40% smaller and - more importantly - became editable enough to update prices in minutes instead of an afternoon.

The agency handoff snippet. A contractor delivered a landing section as a full-page export with inline styles on every tag. Cleaning it into a formatted fragment, then moving the styles into one scoped style block, halved it and made it safe for a code block - the same scenario from Squarespace Custom Code: What You Can Safely Paste.

The template reseller. Purchased templates ship with comment banners and empty placeholder divs from the demo. A quick format-and-strip pass before customization makes every later edit faster, and the element-count check guarantees the demo's structure survived intact.

Wrapping up

Exported HTML is not broken; it is unwashed. The sequence - format, strip comments, verify the element count, then edit content on a copy - takes a few minutes per page, needs no code editor, and turns every future edit of that page from an archaeology project into a search-and-replace. The full working routine for the edit that follows is in our guide to editing an HTML template without breaking the layout.