AI Dev Tools

Ruby Console: typed_print gem kills hash dump squinting

The Ruby console is great. Until you're staring at a wall of unformatted hashes. Dev Ender Ahmetyurt built a gem to fix that.

Example of typed_print output showing a clean, aligned table of Ruby hash data.

Key Takeaways

  • The `typed_print` gem offers a simple, zero-dependency solution for formatting Ruby hash dumps into readable tables.
  • It provides features like custom alignment, column selection, header renaming, and Markdown output.
  • The gem prioritizes focused functionality over feature bloat, making it ideal for console debugging and CLI tools.

Look, Ruby’s great. The console, for all its quirks, is indispensable. But this?

{:name=>"Alice", :score=>100, :active=>true}
{:name=>"Bob", :score=>42, :active=>false}

This is eye torture. Especially when you’ve got twenty, fifty, a hundred of them. Squinting becomes a competitive sport. It’s 2023 (or whenever you’re reading this), not 1998. We’ve got better tools. Apparently.

So, Ender Ahmetyurt built typed_print. And it does exactly one thing. Just one. It takes your messy hash dumps and turns them into clean, aligned tables.

Here’s the magic. Or, you know, the code:

```ruby require ‘typed_print’ data = [ { name: “Alice”, score: 100, active: true }, { name: “Bob”, score: 42, active: false } ] TypedPrint.print(data)


And the output? Miraculously readable:

Name Score Active ------+------+------- Alice 100 true Bob 42 false


No complex setup. No arcane syntax. Just… output. Compare that to `pp`, which is marginally better but still a slog for scanning. And `awesome_print`? Great, if you want a dependency bloat party. This gem wants none of that. Zero required dependencies. It just *works*. Everywhere.

## Why Did We Need This? (Besides the Squinting)

The brilliance here is its utter lack of ambition beyond the core problem. It’s not trying to be the next big <a href="/tag/debugging/">debugging</a> framework. It’s not trying to parse your existential dread. It’s a tool for developers. Developers who spend too much time staring at raw data in a terminal and not enough time actually developing. It’s for Rails developers debugging in `rails console`, CLI authors wanting to present data with dignity, or frankly, anyone who’s ever hit `Ctrl+C` on a massive, unformatted hash dump out of sheer frustration.

The added features are equally focused. Need to align a specific column to the right? Done.

```ruby
TypedPrint.print(data, align: { score: :right })

Only want to see specific keys? Easy.

TypedPrint.print(data, only: [:name, :score])

Want friendlier headers than :symbol_names? Sure.

TypedPrint.print(data, headers: { name: "User", score: "Points" })

And for those who need to copy-paste into documentation or issues? Markdown format. Boom.

TypedPrint.print(data, format: :markdown)

It even handles color if you have pastel installed, but if not? No errors. It just gracefully degrades. That’s the kind of grace we need more of in the dev tools space. Less ‘everything including the kitchen sink,’ more ‘does this one thing perfectly.’

Is This Just Another pp? (No, and thank goodness)

Let’s be clear: pp pretty-prints. typed_print formats. The distinction might seem minor, but it’s the difference between a slightly less awful wall of text and an actual, scannable data representation. The author explicitly wanted something that wasn’t pp and wasn’t the kitchen-sink approach of awesome_print. The goal: simplicity. Zero dependencies. Just tables. And it delivers.

It handles nil, booleans, numbers, and strings without fuss. It’s tested up to 10,000 rows. Fast enough for CLI tools and debugging. The author rightly points out that if you’re printing 100,000 rows to a terminal, you probably have bigger problems – or you’re doing it wrong. This isn’t for big data analytics; it’s for making your workflow less painful.

It’s the kind of pragmatic, focused tool that makes you wonder why it didn’t exist sooner. It’s the digital equivalent of realizing you can just use a ruler to draw a straight line instead of trying to freehand it for the hundredth time.

Here’s what you need to do. Assuming you have Ruby installed, which, let’s face it, you probably do if you’re reading this:

gem install typed_print

And that’s it. Done. Install it, require 'typed_print', and start using TypedPrint.print. Report bugs. Suggest features that fit the philosophy. It’s refreshing to see a project that’s receptive to community input without losing its core identity.

This isn’t a paradigm shift. It’s a tiny, elegant solution to a persistent, annoying problem. And in the world of dev tools, sometimes that’s more valuable than any ‘game-changing’ hype.


🧬 Related Insights

Frequently Asked Questions

What does typed_print actually do? typed_print formats arrays of Ruby hashes into clean, aligned tables for better readability in the console or CLI tools. It focuses on providing a simple, zero-dependency solution.

Will typed_print replace my existing pretty-printing tools? It’s designed to complement, not replace. While it offers cleaner table formatting than pp or awesome_print for certain use cases, those tools have their own strengths and wider feature sets.

Can I use typed_print in a project with many dependencies? Yes. typed_print has zero required dependencies, making it suitable for even the most dependency-averse projects.

Written by
DevTools Feed Editorial Team

Curated insights, explainers, and analysis from the editorial team.

Frequently asked questions

What does `typed_print` actually do?
`typed_print` formats arrays of Ruby hashes into clean, aligned tables for better readability in the console or CLI tools. It focuses on providing a simple, zero-dependency solution.
Will `typed_print` replace my existing pretty-printing tools?
It's designed to complement, not replace. While it offers cleaner table formatting than `pp` or `awesome_print` for certain use cases, those tools have their own strengths and wider feature sets.
Can I use `typed_print` in a project with many dependencies?
Yes. `typed_print` has zero required dependencies, making it suitable for even the most dependency-averse projects.

Worth sharing?

Get the best Developer Tools stories of the week in your inbox — no noise, no spam.

Originally reported by dev.to

Stay in the loop

The week's most important stories from DevTools Feed, delivered once a week.