HTML5 Beautifier is an extension to Ruby that processes an HTML5 document and reformats it with a correct indentation.


  • Removes blank lines
  • Indents markup using two spaces by default
  • Does not touch preformatted elements


Ruby on Rails

Add this line to your application’s Gemfile:


gem “html5-beautifier”

And then execute:

$ bundle

Other Ruby applications

Install the gem:

$ gem install html5-beautifier


Ruby on Rails

“Hello World”.beautify

Other Ruby applications

Require the gem:

require “html5-beautifier”

Then use it:

puts “Hello World”.beautify


The above example outputs:

<! DOCTYPE html>
<p>Hello World</p>



  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am ‘Add some feature’)
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request


If you have any questions or issues with HTML5 Beautifier, or if you like to report a bug, please create an issue on GitHub or send email to info at jarijokinen dot com.


MIT License. Copyright © 2012 Jari Jokinen. See LICENSE for further details.