SQL Formatter for Ruby
Free online sql formatter with Ruby code examples
Working with sql formatter in Ruby? Our free online sql formatter helps Ruby developers format, validate, and process data instantly. Below you will find Ruby code examples using anbt-sql-formatter so you can achieve the same result programmatically in your own projects.
Try the SQL Formatter Online
Use our free SQL Formatter directly in your browser — no setup required.
Open SQL FormatterRuby Code Example
require 'anbt-sql-formatter/formatter'
rule = AnbtSql::Rule.new
rule.keyword = AnbtSql::Rule::KEYWORD_UPPER_CASE
formatter = AnbtSql::Formatter.new(rule)
sql = "select u.name, u.email, o.total from users u join orders o on u.id = o.user_id where o.total > 100 order by o.total desc;"
formatted = formatter.format(sql)
puts formattedQuick Setup
Library: anbt-sql-formatter
gem install anbt-sql-formatterRuby Tips & Best Practices
- anbt-sql-formatter provides configurable SQL formatting
- Use KEYWORD_UPPER_CASE for uppercase SQL keywords
- niceql gem is an alternative with colorized output