---
title: 'Introducing props_template: A Jbuilder alternative'
teaser: We've built props_template, a faster Jbuilder that supports layouts, digging,
  and more!.
tags: ruby,web,ruby on rails,json,superglue,jbuilder
author: Johny Ho
published_on: 2024-03-08
---

I like [Jbuilder](https://guides.rubyonrails.org/action_view_overview.html#jbuilder). It’s been part of every Rails project every time I run `rails
new` and the first thing I reach for when I want to create JSON responses. It’s
as synonymous with JSON as ERB is with HTML.

But I wanted a version of Jbuilder that had [layouts], didn’t merge hashes, had
faster [caches], directly used [OJ's StringWriter] instead of building a hash,
and allowed me to [dig] into a structure using a key path.  Sometimes it makes
sense to contribute to an open source project and submit pull requests for the features you
want; sometimes we diverge so much that it makes sense to start anew.

Introducing [props_template]. A JSON builder with a Jbuilder-like DSL that
has support for all of the previously mentioned and more!

It’s fast.

![Benchmark of props_template, Jbuilder, rabl, ams, fast_json, turbostreamer](https://images.thoughtbot.com/jx8ma9de1y8vj7kw3xxb2myumleg_benchmarks.png)

And doesn’t compromise on the DSL by staying as close as possible to Jbuilder.

```ruby
# index.json.props

json.menu do
  json.current_user do
    json.email current_user.email
    json.avatar current_user.avatar
    json.inbox current_user.messages.count
  end
end

json.posts do
  json.array! paged_posts do |post|
    json.id post.id
    json.description post.description
    json.comments_count post.comments.count
    json.edit_path edit_post_path(post)
  end
end

json.footer partial: 'shared/footer' do
end

```

[props_template] was built to generate JSON for [superglue], a framework that
makes React and Redux as productive as Hotwire, Turbo and Stimulus. Give that a
try too!

[dig]: https://github.com/thoughtbot/props_template?tab=readme-ov-file#traversing
[OJ's StringWriter]: https://www.rubydoc.info/gems/oj/Oj/StringWriter
[superglue]: https://thoughtbot.com/blog/introducing-superglue
[props_template]: https://github.com/thoughtbot/props_template
[Oj]: https://github.com/ohler55/oj
[layouts]: https://github.com/thoughtbot/props_template?tab=readme-ov-file#layouts
[caches]: https://github.com/thoughtbot/props_template?tab=readme-ov-file#caching
