Ruby Formatter Beautifier
Format common code, data, markup, and document languages locally in your browser.
Format common code, data, markup, and document languages locally in your browser.
The formatter re-indents Ruby with two spaces per level: def, class, module, if, case, begin, do blocks and brackets open a level and end closes it, while trailing modifiers such as return if x.nil? and endless methods (def y = 1) do not. Heredocs and =begin comments are kept verbatim. A flush-left def hi(name) body is indented to puts "Hi #{name}".