Introduction

Panko is a library for serializing ActiveRecord/Ruby objects to JSON strings, fast.

It reaches its performance through a few choices:

  • Code generation. Panko compiles a specialized serializer, in plain Ruby, once per serializer class, so per-record serialization is straight-line code rather than a metadata-driven loop.
  • Auto-specialization. The first time a serializer meets an ActiveRecord class, Panko compiles a variant for that model that reads columns straight from its attribute storage.
  • Oj. Panko builds JSON incrementally with Oj::StringWriter, skipping the intermediate Hash most serializers allocate.

The engine is pure Ruby: there is no native extension to compile when you install the gem. To dig into these choices, read Design Choices.

Ready to write your first serializer? Head to Getting Started. Upgrading from 0.8? Read Upgrading from 0.8.



Copyright © 2026 Panko Serializer. Distributed under the MIT License.

This site uses Just the Docs, a documentation theme for Jekyll.