ERB beautifier and minifier
Format or compact ERB source locally, with copy and file download.
A clear answer. Here’s how.
Formats HTML with js-beautify’s ERB-aware tokenizer; Ruby blocks are preserved and never run. Conservative minification compacts whitespace inside tags and removes ordinary comments, preserving conditional and directive comments, every text node, quoted attribute value, ERB block and raw script, style, pre and textarea content. It does not minify embedded languages, validate a page or guarantee that beautifying whitespace-sensitive markup is visually identical. Up to 200,000 characters.
How this is checked
2 reference checks passed These 2 cases were run when this page was built, on 3 December 2026, and all reproduce within the stated tolerance. The same cases are part of the automated tests that run on every change to Toolmoz. Engine version 1.
See the checks and where each expected answer comes from
Case 1
- Inputs
- Source <p class="x" ><%= name %></p>Output minify
- Expected, and what Toolmoz gave
- text expected <p class="x"><%= name %></p>, Toolmoz <p class="x"><%= name %></p>
- Where the expected answer comes from
- Compact attribute separators but keep the ERB expression byte-for-byte.
- Allowed difference
- exact
Case 2
- Inputs
- Source <% if x %> a b <% end %>Output minify
- Expected, and what Toolmoz gave
- text expected <% if x %> a b <% end %>, Toolmoz <% if x %> a b <% end %>
- Where the expected answer comes from
- ERB blocks and text whitespace between them are opaque and preserved.
- Allowed difference
- exact
What this shows: the engine reproduces independently worked values for these cases. It does not prove every possible input is right. To test an answer you were given, see how to check a number; to see what is and is not checked across Toolmoz, see the accuracy ledger.
See a worked example
Worked example
A fixed demonstration, separate from the values you enter above.
- Source
- <ul><% items.each do |item| %><li><%= item.name %></li><% end %></ul>
- Output
- Beautify
- Indent
- 2 spaces
Example result
<ul><% items.each do |item| %> <li><%= item.name %></li><% end %> </ul>
Source is parsed locally and never executed. Review formatting before using the result.