How to format HTML code
Copied or generated HTML often arrives on one line. The formatter nests tags with clean indentation so you can read and edit it.
Step by step
- Paste your code. Type or paste it into the left box, or paste a snippet from your editor.
- Choose options. Pick the indent size or other settings. The result updates as you type.
- Copy or download. Copy the result or save it as a file.
Tips for better results
- Embedded script and style blocks are formatted with the CSS and JavaScript formatters.
- Text inside pre and textarea is left exactly as written.
- Fix unclosed tags yourself; the formatter does not repair broken markup.
Limits to know
- Formats: HTML
- Size: Limited by browser memory
- Notes: Runs fully in your browser. Very large inputs (several MB) can slow the page.
At a glance
| Tool | HTML Formatter |
|---|---|
| Category | Developer Tools |
| Works with | HTML |
| Size limit | Limited by browser memory |
| Where it runs | In your browser tab; your input is not uploaded |
| Cost | Free, no sign-up |
Frequently asked questions
Does it change how the page looks?
It only changes whitespace between tags. Content inside pre, textarea, script and style is preserved.
Does it fix invalid HTML?
No. It formats what you give it; it does not correct mistakes.
If something does not work
- The result is empty. Check that you typed or pasted text into the input box and that the options are not hiding everything.
- The page feels slow. Very large text slows any browser tool. Work on smaller parts.
- Characters look wrong. Make sure the text is saved as UTF-8 in the program you copied it from.
- Copy does not work. Some browsers block automatic copying; select the result and copy it yourself.
Still stuck? Use Report a Problem and tell us the tool, your browser and what happened, or read the Help Center.
Related tools and guides
- JSON Formatter: Format, indent, sort and minify JSON. Invalid JSON is reported with the line and column of the problem. Read the guide
- JSON Validator: Check whether your JSON is valid. If it is not, see the exact line and column and a plain-English reason. Read the guide
- CSS Formatter: Turn compressed CSS into readable code with one declaration per line and consistent indentation. Read the guide
More tools like this are in Developer Tools, or browse all tools.