HTML Tidy
Turn broken, messy HTML into clean markup with every tag closed and neat indentation.
Add HTML and click Tidy to see clean code here.
How HTML Tidy works
Cleans up broken or messy HTML. Your HTML is read the same way a browser reads it, so tags left open get closed and wrongly nested tags are put in the right order. Missing html, head and body tags are added. Then the code is indented so it is easy to read.
You can also remove comments, empty attributes and inline styles. After each run a note tells you what was fixed and how many items were removed.
Input to HTML Tidy
- Paste or type HTML into the input box, or upload a .html, .htm or .txt file. Input needs at least one tag.
- Remove comments (on by default): drops HTML comments.
- Remove empty attributes (on by default): drops attributes like class="". Boolean attributes like checked, and alt, value, data-* and aria-* attributes, are kept.
- Remove inline styles (off by default): drops every style attribute.
- Output: Full document gives the whole page with a doctype, Body only gives just what is inside body. Indent: 2, 3 or 4 spaces or tabs. Change an option and the output updates right away.
Output from HTML Tidy
- Clean, indented HTML with every tag closed.
- If your input has no doctype, Full document adds <!DOCTYPE html>.
- Copy it, download it as a .html file or open it in full screen. Everything runs in your browser and files can be up to 20MB.