Sign up free

Online HTML Formatter and Beautifier

Paste minified or messy HTML and get clean, indented markup that's easy to read and edit.

About HTML Formatter

An HTML formatter helps when markup arrives as one long line or with random indentation: the source of a page you copied with View Page Source, a template exported from a page builder, an HTML email, or a snippet pasted out of a CMS editor. Paste the code or open a file, and the formatted version appears as you type, indented with 2 spaces, 4 spaces or tabs.

Block tags such as div, p, ul and table go on their own lines, while inline tags like a, span, b and em stay in the text, so sentences aren't chopped into pieces. Anything inside pre and textarea is left exactly as it was, because spacing matters there. Embedded style and script blocks are formatted too, unless you untick Also format CSS and JavaScript inside, and comments are kept. To shrink a page instead, use the HTML Minifier. The code never leaves your browser, and the tool keeps working offline once the page has loaded.

How to use HTML Formatter

  1. 1
    Paste your HTML

    Paste the markup into the box or open an HTML file from your computer.

  2. 2
    Pick the indent

    Choose 2 spaces, 4 spaces or tabs, and the HTML formatter updates the result at once.

  3. 3
    Copy or download

    Copy the formatted HTML or download it as a file.

Why use Cubfile for this

  • Sensible line breaks

    Block tags get their own lines, and inline tags such as a, span and em stay in the text.

  • Pre and textarea kept

    Content where spacing matters is left exactly as you wrote it.

  • CSS and JS inside too

    Embedded style and script blocks are formatted along with the markup, an option that's on by default.

  • Private and offline

    Runs in your browser, uploads nothing and keeps working without a connection once loaded.

FAQ

HTML Formatter: questions and answers

How do I format HTML code online?
Paste the HTML or open the file, pick 2 spaces, 4 spaces or tabs, and copy the result. It updates as you type, with nothing to install and no sign-up.
Will the HTML formatter change how my page looks?
It only changes whitespace: line breaks, indentation and repeated spaces. Inline tags stay inside the text and pre and textarea content isn't touched, so in normal layouts the page looks the same.
Does it also format CSS and JavaScript inside the HTML?
Yes, by default. Embedded style and script blocks are formatted with the markup, and unticking Also format CSS and JavaScript inside leaves their code unformatted. For separate .css or .js files, use the CSS Formatter or the JavaScript Formatter.
Are HTML comments removed?
No, comments are kept where they are. To strip them before publishing, run the code through the HTML Minifier.
Does the HTML formatter upload my code?
No. Formatting happens in your browser, so nothing reaches our server, it doesn't count toward any daily limit, and it works offline once the page has loaded.
Share HTML Formatter with a friendIt runs in any browser, and they can try it without signing up.

Related tools

JS JavaScript FormatterBeautify minified or messy JavaScript.
HEX Color ConverterConvert colors between HEX, RGB, HSL and CMYK, and check contrast.
CRON Cron Expression GeneratorBuild cron expressions and see the next run times in plain words.
CSS CSS FormatterTurn minified CSS into neat, readable rules.
CSS CSS MinifierMinify CSS to load faster.
HTML HTML MinifierShrink HTML by removing comments and extra whitespace.
HTTP HTTP Request TesterSend GET, POST and other requests to a public API and read the response.
JS JavaScript MinifierStrip comments and whitespace from JavaScript without changing how it runs.