Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Static Analysis & Code Quality
  3. htmlbeautifier

htmlbeautifier

MITRuby

A Ruby gem that normalizes and beautifies HTML, including embedded Ruby code, ideal for Rails templates.

GitHubGitHub
374 stars62 forks0 contributors

What is htmlbeautifier?

HTML Beautifier is a Ruby gem that normalizes and beautifies HTML files, including those with embedded Ruby (ERB) code. It solves the problem of messy, inconsistently formatted HTML in Rails templates by applying consistent indentation, removing trailing spaces, and handling Ruby block structures. The tool ensures HTML files are clean and readable, whether used via command line or integrated into Ruby code.

Target Audience

Ruby on Rails developers working with ERB templates who need to maintain clean, consistently formatted HTML files. It's also useful for developers using embedded Ruby in other contexts who want automated HTML beautification.

Value Proposition

Developers choose HTML Beautifier because it specifically understands embedded Ruby syntax, unlike generic HTML formatters, making it ideal for Rails projects. It's lightweight, easy to use via command line or as a library, and provides customizable indentation options.

Overview

A normaliser/beautifier for HTML that also understands embedded Ruby. Ideal for tidying up Rails templates.

Use Cases

Best For

  • Cleaning up messy HTML in Rails ERB templates
  • Automating HTML formatting in Ruby-based build pipelines
  • Ensuring consistent indentation in mixed HTML/Ruby files
  • Pre-commit hooks for formatting HTML in version control
  • Improving readability of legacy Rails template code
  • Formatting HTML with embedded JavaScript or CSS blocks

Not Ideal For

  • Projects using JavaScript frameworks with JSX or Vue templates, where embedded Ruby support is irrelevant
  • Teams needing advanced HTML validation or linting features beyond basic formatting
  • Environments where integration with non-Ruby build tools or CI/CD pipelines is required
  • Developers working primarily with templating languages like HAML or Slim that have their own formatters

Pros & Cons

Pros

Embedded Ruby Expertise

It correctly indents and outdents Ruby blocks like if and do, and handles elsif clauses, making it uniquely effective for Rails ERB templates as highlighted in the README.

Customizable Indentation Options

Allows specifying indentation with spaces or tabs via the indent parameter, providing flexibility for different coding styles.

Whitespace Cleanup

Removes trailing spaces and collapses multiple whitespace, ensuring consistently clean HTML output without unnecessary clutter.

Command-Line Simplicity

Can format files in-place or via standard input from the terminal, making it easy to automate in scripts or pre-commit hooks.

Cons

Ruby-Only Ecosystem

Requires Ruby installation and is designed for Ruby projects, limiting its use in polyglot environments or teams not using Ruby.

Limited Configuration

Lacks support for configuration files to store formatting preferences, relying on manual command-line arguments or code parameters for each use.

Basic Feature Set

Focuses on indentation and whitespace; it doesn't offer advanced features like HTML minification, attribute sorting, or syntax error checking.

Frequently Asked Questions

Quick Stats

Stars374
Forks62
Contributors0
Open Issues11
Last commit2 years ago
CreatedSince 2009

Tags

#rails-templates#ruby-gem#html-formatter#code-formatting

Built With

R
Ruby

Included in

Static Analysis & Code Quality14.5k
Auto-fetched 9 hours ago

Related Projects

GitleaksGitleaks

Find secrets with Gitleaks 🔑

Stars29,157
Forks2,229
Last commit13 days ago
PHP ParserPHP Parser

A PHP parser written in PHP

Stars17,465
Forks1,134
Last commit2 days ago
TypeScript ESLintTypeScript ESLint

:sparkles: Monorepo for all the tooling which enables ESLint to support TypeScript

Stars16,390
Forks3,002
Last commit13 hours ago
pyrightpyright

Static Type Checker for Python

Stars15,625
Forks1,809
Last commit4 days ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub