HTML to HAML Converter
Convert HTML into the indented HAML syntax, with no closing tags and shorthand class and id syntax. Paste your HTML and get HAML — great for Ruby on Rails views.
Copiado!
Para HTML bem-formado. Não cobre <script>/<style> com conteúdo nem tags mal-fechadas.
Cada elemento começa com %. <p>Olá</p> vira %p Olá.
Use shorthand: %div.classe#id. Aninhe por indentação (2 espaços).
Atributos: %a{href: "/x", target: "_blank"} link.
Paste HTML, get indented HAML back
You inherited a Rails view full of angle brackets and the team writes HAML now. Converting by hand is dull work, and dull work is exactly where the indentation slips and quietly reparents half the markup. Paste the HTML into the top box and the indented version shows up below, with %tag lines, attributes in braces and no closing tags to keep track of.
Conversion runs through a small hand-written parser built on regular expressions, with no DOM involved. It knows the void elements (img, br, input, meta and friends) and never opens a block for them, turns HTML comments into slash lines, and applies the div shorthand, so a div carrying a class collapses to .card. Attributes become a hash: a link with href comes out as %a{href: "/x"} link.
It expects well-formed markup. Unclosed tags, the contents of script or style, and CDATA blocks sit outside what the parser handles. Text nodes are trimmed, so a paragraph with bold text in the middle becomes three lines and loses the space between words; stitch those back by hand. Boolean attributes such as required arrive with an empty string value, and the doctype passes through as literal text, so swap it for !!!. It converts in your browser.
Frequently asked questions
Does it understand ERB or Ruby?
Does deep nesting survive?
Can it go from HAML back to HTML?
Related Tools
HTML to Pug Converter
Convert HTML into the indentation-based Pug (formerly Jade) syntax, with no closing tags. Paste your HTML and get the Pug version — great for Node.js and Express.
JSX to HTML Converter
Converts JSX (React) syntax to plain HTML by mapping className to class and camelCase attributes to kebab-case.
AsciiDoc → HTML (basic)
Render simple AsciiDoc to HTML: headings = == ===, paragraphs, lists, emphasis. Does not cover advanced extensions like includes.
HTML to JSX
Convert HTML to React JSX automatically. Transforms class→className, for→htmlFor, converts attributes to camelCase and closes void tags.
Measurements Converter
Convert between units of length, mass, temperature, area, volume and speed. Instant result in the browser.
Date Format Converter
Convert dates between the most common formats: dd/mm/yyyy, yyyy-mm-dd, mm/dd/yyyy, ISO 8601 and Unix timestamp.