Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
N

niceql

> 编程语言
Open source

niceql gem repo. Nice, colorized SQL formatting in ruby.

326 stars0 likes3 views
WebsiteGitHub

About

niceql gem repo. Nice, colorized SQL formatting in ruby.

Niceql

ATTENTION: After ver 0.5.0 the ActiveRecord integration is provided via standalone gem: rails_sql_prettifier!

This is a small, nice, simple and zero dependency solution for SQL prettifying for Ruby. It can be used in an irb console without any dependencies ( run bin/console and look for examples ).

Any reasonable suggestions are welcome.

Before/After

SQL prettifier:

PG errors prettifier

before:

after:

Installation

Add this line to your application's Gemfile:

ruby
gem 'niceql'

And then execute:

$ bundle
# if you are using rails, you may want to install niceql config:
rails g niceql:install 

Or install it yourself as:

$ gem install niceql

Configuration

…

Usage

With ActiveRecord ( you need rails_sql_prettifier for that! )

ruby
  # puts colorized and formatted corresponding SQL query
  Model.scope.niceql
  
  # only formatting without colorization, you can run output of to_niceql as a SQL query in connection.execute  
  Model.scope.to_niceql
  
  # prettify PG errors if scope runs with any 
  Model.scope_with_err.exec_niceql 

Without ActiveRecord

…

Customizing colors

If your console support more colors or different schemes, or if you prefer different colorization, then you can override ColorizeString methods. Current colors are selected with dark and white console themes in mind, so a niceql colorization works good for dark, and good enough for white.

Limitations

Right now gem detects only uppercased form of verbs with simple indentation and parsing options.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/alekseyl/niceql.

License

The gem is available as open source under the terms of the MIT License.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Ruby

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言