HTML Beautifier Online Tool



About HTML Beautifier Online Tool:

This online html beautifier tool helps you to format raw HTML file so it can easily be read by human being.

comic html beautifier

More information about HTML (Hypertext Markup Language):

W3 HTML 5.2 standard: https://www.w3.org/TR/html5/

RFC 7992 (HTML): https://tools.ietf.org/html/rfc7992

Python Implementation of HTML (BeautifulSoup): https://www.crummy.com/software/BeautifulSoup/

HTML Formatter with Python (with package BeautifulSoup):

def html_beautify(input_str):
    input_str = BeautifulSoup(input_str, 'html.parser').prettify()
    result = ''
    indent_str = '    '
    for line in input_str.split('\n'):
        lstrip_line = line.lstrip(' ')
        indent_len = len(line) - len(lstrip_line)
        formatted_line = indent_len * indent_str + lstrip_line
        result = result + formatted_line + '\n'
    return result