HTML to Haml Converter

Transform HTML/ERB into Haml with ease. Built for Rails developers who value clean, structured code.

Tags: convert code erb haml html rails template converter

🚀 359,329 total conversions (8 this month)

Practice Python with coding challenges

Solve hands-on problems right in this editor: run the sample tests, submit, and get an AI code review.

All Python challenges
Hard

Course Schedule Order

Order courses so every prerequisite comes first.

AdvancedGraphsHackathonTopological-sort
No solutions yet
Medium

Island Perimeter

Measure the coastline of land cells in a grid.

AdvancedGridsHackathon
No solutions yet
Medium

K-th Smallest Element

Find the k-th smallest value without fully sorting.

AdvancedCompetitive-programmingSorting
No solutions yet
Hard

Median of Two Sorted Arrays

Find the median of two sorted lists combined.

AdvancedBinary-searchCompetitive-programming
No solutions yet
Medium

Game of Life Step

Advance Conway's Game of Life by one generation.

AdvancedGridsHackathonSimulation
No solutions yet
Hard

Shortest Delivery Tour

Visit every city once and return home as cheaply as possible.

AdvancedBitmasksCompetitive-programmingDynamic-programming
No solutions yet
Hard

Strongly Connected Components

Count groups of nodes that can all reach each other.

AdvancedCompetitive-programmingGraphs
No solutions yet
Hard

Longest Path in a DAG

Find the heaviest path in a task dependency graph.

AdvancedGraphsHackathonTopological-sort
No solutions yet
Hard

Matrix Chain Multiplication

Find the cheapest order to multiply a chain of matrices.

AdvancedCompetitive-programmingDynamic-programming
No solutions yet
Hard

Minimum Window Substring

Find the shortest piece of text containing all required characters.

AdvancedCompetitive-programmingSliding-windowStrings
No solutions yet
Hard

Word Break

Decide whether text can be split into dictionary words.

AdvancedDynamic-programmingHackathonStrings
No solutions yet
Hard

Count Inversions

Count the out-of-order pairs in a list.

AdvancedCompetitive-programmingSorting
No solutions yet

What is This Tool?

This free online converter helps you instantly convert HTML and ERB (Embedded Ruby) templates into clean, readable Haml code. It’s ideal for Ruby on Rails developers who want to simplify and modernize their views.

How to Use

  1. Paste or type your HTML+ERB code into the editor.
  2. Click Convert to generate Haml.
  3. Download, copy, or share the Haml result instantly.

You can also sign in with Google or GitHub to save your conversion history and download files later.

Why Haml?

Haml (HTML Abstraction Markup Language) is a whitespace-sensitive templating engine for Ruby, commonly used in Rails. It replaces inline HTML with clean, indented syntax that’s easier to read and maintain.

Benefits of Haml include:

  • Cleaner and shorter syntax compared to ERB
  • Improved readability and maintainability
  • Faster front-end templating for Rails developers

Haml is used by many Ruby shops and developers for rapid Rails development, including Unspace Interactive.

Learn more at the official Haml website.

Haml Syntax Example


%section.container
  %h1= post.title
  %h2= post.subtitle
  .content
    = post.content

    

HTML+ERB vs Haml Example

HTML+ERB


<!doctype html>
<html>
  <head>
    <meta charset="utf-8"/>
  </head>
  <body>
    <h1>Blogg</h1>
    <p>Time: <%%= Time.now %%></p>
    <%% Post.all.each do |post| %%>
      <article>
        <h2><%%= post.title %%></h2>
        <div><%%= post.body %%></div>
      </article>
    <%% end %%>
  </body>
</html>

Haml


!!!
%html
  %head
    %meta{ content: "text/html; charset=UTF-8", "http-equiv": "Content-Type" }/
    %meta{ charset: "utf-8" }/
  %body
    %h1 Blogg
    %p
      Time:
      \#{Time.now}
    - Post.all.each do |post|
      %article
        %h2= post.title
        %div= post.body