Text UtilitiesText FormattersFree Tool
Ruby Formatter
Apply basic indentation to Ruby code, including its end/else keywords — not a real parser, so complex code may not indent perfectly.
How to Use Ruby Formatter
- 1Paste your Ruby code
- 2Click Convert
- 3Copy the re-indented output — verify against RuboCop for anything beyond simple code
Frequently Asked Questions
Unlike the other language formatters here, this one specifically recognizes Ruby's end and else keywords (which close do/if/def/class blocks in Ruby) alongside standard brackets when deciding indentation depth.
Only partially — it recognizes the end keyword and brackets, but doesn't distinguish between Ruby's many block-opening constructs (def, class, if, do, module, etc.) the way a real parser would.
RuboCop (with its auto-correct feature) or `rufo` — both use Ruby's real parser for correct formatting.
No — the indentation pass runs entirely in your browser.
Related Tools
JSON Formatter
Pretty-print JSON with real 2-space indentation using the browser's native JSON parser — shows the exact parse error if your JSON is invalid.
JSON Minifier
Compress JSON to its smallest valid form by removing all whitespace, using the native JSON parser.
XML Formatter
Reformat XML with proper nested indentation based on tag depth — a lightweight tag-based indenter, not a full XML parser.
XML Minifier
Compress XML by stripping comments and collapsing whitespace between tags.