# rails-api/active_model_serializers

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/rails-api-active-model-serializers).**

5,342 stars · 1,378 forks · Ruby · MIT

## Links

- GitHub: https://github.com/rails-api/active_model_serializers
- awesome-repositories: https://awesome-repositories.com/repository/rails-api-active-model-serializers.md

## Topics

`json` `resource-serializer` `ruby`

## Description

Active Model Serializers is a Ruby on Rails JSON serializer used to transform model objects and associations into structured JSON responses for APIs. It functions as a model-to-JSON mapper and response formatter that decouples internal database schemas from external API contracts.

The project utilizes a pluggable adapter pattern to organize serialized data according to specific standards, such as the JSON API specification. It provides a mechanism to map internal attributes to custom JSON keys and implements a serialization scope that allows for attribute and association filtering based on authorization context and user permissions.

The toolset covers data transformation through the use of virtual attributes and the management of associated data via sideloading or ID embedding. It includes capabilities for response metadata injection, fragment-based result caching, and performance instrumentation to track serialization metrics.

## Tags

### Web Development

- [Model to JSON Conversion](https://awesome-repositories.com/f/web-development/model-to-json-conversion.md) — Transforms model objects into structured JSON representations for API responses using a customizable process. ([source](https://github.com/rails-api/active_model_serializers/blob/master/CHANGELOG-0-08.md))
- [Response Formatting](https://awesome-repositories.com/f/web-development/response-formatting.md) — Transforms database models into structured JSON responses for web APIs using a customizable serialization process.
- [Specification Adapters](https://awesome-repositories.com/f/web-development/api-adapters/specification-adapters.md) — Uses a pluggable adapter pattern to format JSON responses according to specific API specifications. ([source](https://github.com/rails-api/active_model_serializers/blob/master/CHANGELOG-0-08.md))
- [Attribute Key Mapping](https://awesome-repositories.com/f/web-development/attribute-key-mapping.md) — Decouples the external API contract from the database schema by mapping internal attributes to custom JSON keys. ([source](https://github.com/rails-api/active_model_serializers/tree/0-8-stable))
- [Specification Adapters](https://awesome-repositories.com/f/web-development/json-api-frameworks/specification-adapters.md) — Provides a formatting layer that organizes serialized data to follow specific standards like the JSON API specification.
- [JSON APIs](https://awesome-repositories.com/f/web-development/json-apis.md) — Builds API endpoints that adhere to specific data standards using pluggable adapters.
- [JSON Structure Adapters](https://awesome-repositories.com/f/web-development/json-structure-adapters.md) — Adjusts the output structure using adapters to satisfy specific API standards or root key requirements. ([source](https://github.com/rails-api/active_model_serializers/tree/v0.10.6/docs))
- [Rails JSON Serializers](https://awesome-repositories.com/f/web-development/rails-json-serializers.md) — Transforms Ruby on Rails model objects and associations into structured JSON responses for APIs.
- [Relationship Mapping](https://awesome-repositories.com/f/web-development/relationship-mapping.md) — Defines how associated models are linked or embedded in JSON outputs to manage payload size.
- [Resource Sideloading](https://awesome-repositories.com/f/web-development/resource-sideloading.md) — Flattens associated data into a separate root-level collection to avoid deep nesting and reduce payload duplication.
- [Response Formatters](https://awesome-repositories.com/f/web-development/response-formatters.md) — Adds pagination metadata and authorization-based filtering to Rails controller responses.
- [Associated Data Sideloading](https://awesome-repositories.com/f/web-development/associated-data-sideloading.md) — Implements sideloading of associated records to simplify client-side parsing and reduce payload duplication. ([source](https://github.com/rails-api/active_model_serializers/tree/0-8-stable))
- [Association ID Embedding](https://awesome-repositories.com/f/web-development/association-id-embedding.md) — Provides the ability to embed only identifiers for associated objects to minimize response size. ([source](https://github.com/rails-api/active_model_serializers/tree/0-9-stable))
- [Document Structure Control](https://awesome-repositories.com/f/web-development/document-structure-control.md) — Controls the final structure of the JSON response, allowing for flat lists or specific specification layouts. ([source](https://github.com/rails-api/active_model_serializers/tree/0-10-stable))

### Data & Databases

- [Serialization Contexts](https://awesome-repositories.com/f/data-databases/data-processing-pipelines/data-serialization/serialization-configuration-managers/serialization-contexts.md) — Passes an authorization context into the serializer to customize output based on user permissions. ([source](https://github.com/rails-api/active_model_serializers/tree/0-9-stable))
- [Authorization-Based](https://awesome-repositories.com/f/data-databases/data-querying/table-item-filters/column-filters/attribute-filtering/authorization-based.md) — Controls which data fields are visible in a response based on the current user identity or authorization level.
- [Nested Serialization](https://awesome-repositories.com/f/data-databases/relational-association-apis/nested-serialization.md) — Automatically embeds related database records into API responses by recursively applying serializers. ([source](https://github.com/rails-api/active_model_serializers/tree/0-9-stable))
- [Association Definitions](https://awesome-repositories.com/f/data-databases/relationship-modeling/association-definitions.md) — Provides a descriptive language to specify how related models are included and represented in the JSON output. ([source](https://github.com/rails-api/active_model_serializers/blob/master/CHANGELOG-0-08.md))
- [API Response Optimizations](https://awesome-repositories.com/f/data-databases/api-response-optimizations.md) — Reduces server load by caching serialized JSON data and monitoring conversion metrics.
- [Serialized Output Caching](https://awesome-repositories.com/f/data-databases/data-caching/serializers/serialized-output-caching.md) — Stores serialized object results as JSON to reduce computation time for repeat requests. ([source](https://github.com/rails-api/active_model_serializers/blob/master/CHANGELOG-0-08.md))
- [Fragment Caches](https://awesome-repositories.com/f/data-databases/data-engineering-infrastructure/caching-performance/caching/template-caches/fragment-caches.md) — Provides fragment caching to store specific serialized object outputs and bypass redundant computation for repeat requests.
- [Resource Serialization Formats](https://awesome-repositories.com/f/data-databases/data-serialization-formats/resource-serialization-formats.md) — Processes collections of resources by applying specific serializers to each item in the group. ([source](https://github.com/rails-api/active_model_serializers/tree/0-10-stable))
- [Casing Transformers](https://awesome-repositories.com/f/data-databases/key-transformers/casing-transformers.md) — Implements global and class-level formatting rules to convert attribute keys into specific casing styles.

### Security & Cryptography

- [Attribute-Based Access Control](https://awesome-repositories.com/f/security-cryptography/attribute-based-access-control.md) — Controls which attributes and associations appear in the output based on the current authorization context. ([source](https://github.com/rails-api/active_model_serializers/blob/master/CHANGELOG-0-08.md))
- [Serialization Attribute Restrictions](https://awesome-repositories.com/f/security-cryptography/oauth-scope-restrictions/serialization-attribute-restrictions.md) — Restricts specific attributes and associations based on the current user identity or authorization level. ([source](https://github.com/rails-api/active_model_serializers/tree/0-8-stable))

### Software Engineering & Architecture

- [Class Instance JSON Serializers](https://awesome-repositories.com/f/software-engineering-architecture/abstract-syntax-tree-tools/internal-tree-representations/json-serializers/dom-to-json-serialization/class-instance-json-serializers.md) — Transforms model or plain Ruby objects into JSON representations using dedicated serializer classes. ([source](https://github.com/rails-api/active_model_serializers/tree/0-9-stable))
- [Adapter-Based Output Formatting](https://awesome-repositories.com/f/software-engineering-architecture/adapter-based-output-formatting.md) — Uses a pluggable adapter pattern to transform internal data structures into specific JSON specifications.
- [Computed Properties](https://awesome-repositories.com/f/software-engineering-architecture/architectural-design-patterns/object-oriented-foundations/object-oriented-programming/attribute-management/computed-properties.md) — Allows the definition of synthetic properties via custom logic within serializer methods.
- [Attribute-Mapping Layer](https://awesome-repositories.com/f/software-engineering-architecture/attribute-mapping-layer.md) — Decouples the external API contract from the internal database schema by mapping model attributes to custom keys.
- [Contextual Serialization Logic](https://awesome-repositories.com/f/software-engineering-architecture/contextual-serialization-logic.md) — Passes external context into the serialization process to filter attributes or associations based on user permissions.
- [Model-to-JSON Mappers](https://awesome-repositories.com/f/software-engineering-architecture/model-to-json-mappers.md) — Decouples database schemas from API contracts by mapping internal attributes to custom JSON keys.
- [Computed Attribute Derivation](https://awesome-repositories.com/f/software-engineering-architecture/deterministic-attribute-derivation/computed-attribute-derivation.md) — Allows the definition of virtual attributes that are computed via custom logic during serialization. ([source](https://github.com/rails-api/active_model_serializers/tree/0-8-stable))

### Programming Languages & Runtimes

- [Object Serialization](https://awesome-repositories.com/f/programming-languages-runtimes/object-serialization.md) — Applies consistent serialization behavior to non-database plain Ruby objects for uniform API responses. ([source](https://github.com/rails-api/active_model_serializers/blob/master/CHANGELOG-0-08.md))
