Code2Img

Ruby code screenshots.

How to screenshot Ruby code properly: what Ruby snippets actually look like, how auto-detection behaves, the theme that reads best, and the settings that keep the card legible.

What people actually paste

Rails-flavoured Ruby dominates: a controller action or a model with has_many, validates, a block with do |x| … end, symbol-keyword arguments (def create(order:, notify: true)), string interpolation ("Order #{id}"), and the modifier forms that make Ruby read like prose (return unless order, items.each_with_index.map). Ruby's end keyword means indentation is decorative and structure is explicit — which is good for screenshots, because a fragment keeps its shape even when pasted out of context.

How auto-detection behaves

Ruby is rule 2, immediately after Python. Triggers: def name (no paren needed), a line that is just end, puts , attr_accessor, and require. Python's rule 1 needs def name(...): with a paren and a colon, so def foo alone goes to Ruby and def foo(a): goes to Python — a clean split in theory. Two real problems: require also matches Node's CommonJS const x = require('y'), and since Ruby is rule 2 it beats the JavaScript rule (13) outright, so a Node snippet renders as Ruby; and a Rails snippet written entirely in block form (items.each do |i| … end) may still miss if it contains none of the five triggers and no def.

Theme that reads best

rose-pine for dark: symbols and strings need to separate, because Ruby cards are full of :symbol and "interpolated #{strings}", and rose-pine keeps those two hues apart without a saturated background. catppuccin-latte for light, paired with rose-pine-moon if you want a second dark variant for the same snippet.

Three tips

Other languages

The same advice, for the languages people paste most.

How Code2Img compares

Feature by feature, against the other code screenshot tools.