Code Formatter · Tutorial
How to tidy HTML exported from a website builder
5 min readbeginnerUpdated
Page builders and CMS editors export working but unreadable HTML. You will format a section so each element is on its own line, its attributes are easy to scan and you can safely edit the text.
What you need
- The Code Formatter
- An HTML snippet exported from a builder, or the example hero section
Steps
Paste the exported HTML
Paste the markup or load the example: a hero section with a heading, a paragraph, a button link and a list, all on one line with an inline style attribute.
See the structure
The section, container and each child now sit on their own lines, indented by depth, so you can see that the list is inside the container and after the button.
<section class="hero" style="padding: 48px 24px; text-align: center"> <div class="container"> <h2 class="title">Spring workshop</h2>Keep sentences intact
Leave Whitespace on Respect inline elements. The strong tag stays inside its sentence, so the words around it keep their normal spacing.
Edit and copy back
Press Use result as input to edit the formatted markup here, or copy it into your editor. Changing text is now easy because each element has its own line.
Try it yourself
Opens the Code Formatter with this tutorial's sample loaded.
Common mistakes
- Choosing Ignore for text-heavy content
- Ignore may put line breaks between inline elements, which can add spaces next to links or bold text. Check the page after pasting it back.
- Formatting only half an element
- Copy whole elements, including their closing tags. A missing closing tag is reported as an error.
- Expecting styles to be moved to a stylesheet
- Formatting only changes layout. Inline style attributes stay where they are.
Next steps
Go back to the Code Formatter, or keep going with one of these: