Pretty JSON of any object
Copy puts JSON.pretty_generate(obj.as_json)The go-to. Works for hashes, arrays, ActiveRecord rows, anything that knows `as_json`.
Quick inspect in irb / pry
Copy jj obj`jj` is Ruby's built-in JSON pretty-printer. Fastest one-liner when you just want a look.
ActiveRecord single row
Copy puts user.as_json.to_jsonSkips the model name wrapping that some serializers add.
ActiveRecord collection
Copy puts User.where(active: true).map(&:as_json).to_jsonUse `.map(&:as_json)` so you serialize each record, not the relation.
Nested AR with associations
Copy puts user.as_json(include: { posts: { include: :comments } }).to_jsonPull child records inline so the diff covers the whole tree.
Hash with symbol keys
Copy puts obj.deep_stringify_keys.to_jsonForces symbol keys to strings so the JSON parser is happy.
Raw pp output (use Normalize toggle)
Copy pp objNo JSON conversion. Paste it raw and let Diffy's normalizer handle the Ruby syntax.
Awesome print (plain)
Copy ap obj, plain: true, html: false`plain: true` strips colors; `html: false` keeps it terminal-safe.
File.write("/tmp/a.json", JSON.pretty_generate(obj.as_json))For huge payloads. Write to disk and upload the file via drag-and-drop.
Compare two AR records at once
Copy puts JSON.pretty_generate([before.as_json, after.as_json])Emits an array of two. Split into left/right manually, or paste both halves separately.
API response in a Rails request spec
Copy puts JSON.pretty_generate(JSON.parse(response.body))Re-parse + re-serialize so symbol ordering is consistent.
Filter out noisy keys at source
Copy puts JSON.pretty_generate(obj.as_json.except("updated_at", "created_at"))Alternative to Diffy's ignore rules. Strip in Ruby before pasting.