HTML formatter
Format HTML source with consistent indentation and review the result as text.
- 1Add input
- 2Adjust settings
- 3Get your result
Tool input and files are processed in this browser without being uploaded.
Before you start
Format HTML source locally with Prettier, including supported embedded JavaScript and CSS. The result is displayed as code text; its markup and scripts are not run. Formatting is not validation, and embedded-code errors may not stop a result from being produced.
How to use this tool
- Paste source into “HTML input” or select a local UTF-8 file. Clear the pasted text to use a selected file, or remove the file to use pasted text alone.
- Choose Indentation and String quote preference, then select “Format HTML”.
- Review the complete formatted source, then use “Copy result” or download formatted.html. Check embedded scripts and styles before using the result.
Supported inputs and limits
Paste up to 1 MiB of UTF-8 text, or select one file up to 10 MiB. Nonempty pasted text takes priority over the file; clear the text to format the file instead.
Filenames are limited to 512 UTF-16 code units; some characters, including emoji, use two. A selected file is still checked and read even when pasted text takes priority. When used as input, the file must decode as UTF-8.
Worked example
Example input
<div><p>Hello</p></div>
Example options
{}Example output
<div><p>Hello</p></div>
When something does not work
Check the input size, filename and formatting options. For a formatting error, review the source; when using a file, save an external UTF-8 copy and select it again if needed. Remove a file you are not using. After changing the input, format again to update the result; after cancelling, you can start another run.
Frequently asked questions
Are my files uploaded?
No. Input is processed in your browser. The same tab may temporarily retain a workspace while you switch tools, subject to memory limits. Refreshing or closing the tab clears it. Download any formatted source you want to keep.
Does a successful result validate the HTML and embedded code?
No. This tool formats source; it does not validate the page or run its scripts. An error while formatting embedded JavaScript or CSS may not be reported as a failure of the whole task. Review the output before using it, especially scripts, styles and whitespace-sensitive content.
Does the quote setting affect only JavaScript?
No. The setting is passed to Prettier as a global string-quote preference, and supported embedded CSS can use it too. It is a preference, not a rule that rewrites every quote character. Review embedded code as well as the HTML.
Documentation & further reading
Related tools
JSON formatter and string tools
Format or minify JSON, sort object keys, or convert between plain text and a JSON string.
JavaScript regex tester
Test JavaScript patterns against text and inspect matches, positions and capture groups.
Compare text
Compare two texts line by line, with a side-by-side view of changes.
CSS formatter
Reformat CSS into readable rules with consistent indentation and spacing.