Interactive HTML visualization of your Rails database schema. Introspects your app's models, associations, and columns, then generates a single self-contained HTML file with an interactive entity-relationship diagram.
No external server, no CDN — just one command and a browser.
Live example — generated from Fizzy, a modern spin on kanban for tracking just about anything, created by 37signals.
Add to your Gemfile:
gem "rails-schema", group: :developmentThen run:
bundle installrake rails_schema:generateThis generates docs/schema.html by default. Open it in your browser.
Rails::Schema.generate(output: "docs/schema.html")Create an initializer at config/initializers/rails_schema.rb:
Rails::Schema.configure do |config|
config.output_path = "docs/schema.html"
config.title = "My App Schema"
config.theme = :auto # :auto, :light, or :dark
config.expand_columns = false # start with columns collapsed
config.exclude_models = [
"ActiveStorage::Blob",
"ActiveStorage::Attachment",
"ActionMailbox::*" # wildcard prefix matching
]
endThe gem parses your db/schema.rb file to extract table and column information — no database connection required. It also introspects loaded ActiveRecord models for association metadata. This means the gem works even if you don't have a local database set up, as long as db/schema.rb is present (which is standard in Rails projects under version control).
- No database required — reads directly from
db/schema.rb - Force-directed layout — models cluster naturally by association density
- Searchable sidebar — filter models by name or table
- Click-to-focus — click a model to highlight its neighborhood, fading unrelated models
- Detail panel — full column list and associations for the selected model
- Dark/light theme — toggle or auto-detect from system preference
- Zoom & pan — scroll wheel, pinch, or buttons
- Keyboard shortcuts —
/search,Escdeselect,+/-zoom,Ffit to screen - Self-contained — single HTML file with all CSS, JS, and data inlined
The gem is available as open source under the terms of the MIT License.
