# typestack/class-transformer

**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/typestack-class-transformer).**

7,334 stars · 520 forks · TypeScript · MIT

## Links

- GitHub: https://github.com/typestack/class-transformer
- awesome-repositories: https://awesome-repositories.com/repository/typestack-class-transformer.md

## Topics

`exposing-getters` `exposing-properties` `transformation` `typescript`

## Description

class-transformer is a TypeScript library that converts plain JavaScript objects into typed class instances and back, using decorators to define transformation rules. It serves as a decorator-based object transformer, JSON deserialization library, and property transformation framework, enabling type-safe serialization and deserialization of class instances.

The library distinguishes itself through comprehensive property filtering and mapping capabilities. It supports excluding properties by default, by prefix, by operation (serialization or deserialization), or by explicit marking, as well as filtering properties by group or version range. Property renaming, stripping extraneous properties, and exposing computed properties from getters or methods are also supported, giving fine-grained control over transformation output.

Beyond basic conversion, class-transformer handles nested object transformation, automatic type conversion to match TypeScript-declared types, and polymorphic type discrimination using discriminator properties. It can transform array and collection elements, apply custom transformation logic, convert date strings to Date objects, and handle method return values. The library also provides deep cloning of class instances and direct serialization to and deserialization from JSON strings.

Documentation covers decorator usage, transformation options, and configuration for all supported features, with examples demonstrating each capability.

## Tags

### Data & Databases

- [Decorated Object Mappers](https://awesome-repositories.com/f/data-databases/object-storage/decorated-object-mappers.md) — Ships a decorator-based object mapper that converts plain objects to class instances and back.
- [Class Instance to Plain Object Converters](https://awesome-repositories.com/f/data-databases/ordered-data-structures/ordered-collection-literals/object-collection-processors/object-transformation/class-instance-to-plain-object-converters.md) — Converts class instances back into plain JavaScript objects for serialization or transmission. ([source](https://cdn.jsdelivr.net/gh/typestack/class-transformer@develop/README.md))
- [Plain Object to Class Instance Converters](https://awesome-repositories.com/f/data-databases/ordered-data-structures/ordered-collection-literals/object-collection-processors/object-transformation/plain-object-to-class-instance-converters.md) — Converts plain JavaScript objects into instances of specified classes with full type structure preservation. ([source](https://cdn.jsdelivr.net/gh/typestack/class-transformer@develop/README.md))
- [Operation-Based Property Filters](https://awesome-repositories.com/f/data-databases/property-based-filtering/application-property-filters/group-based-property-filtering/operation-based-property-filters.md) — Omits properties only during serialization or only during deserialization. ([source](https://cdn.jsdelivr.net/gh/typestack/class-transformer@develop/README.md))
- [Prefix-Based Property Filters](https://awesome-repositories.com/f/data-databases/property-based-filtering/application-property-filters/version-based-property-filtering/prefix-based-property-filters.md) — Omits all properties whose names start with a given prefix. ([source](https://cdn.jsdelivr.net/gh/typestack/class-transformer@develop/README.md))
- [Decorator-Driven Type Converters](https://awesome-repositories.com/f/data-databases/type-mapping-utilities/type-mapping-converters/automatic-type-converters/decorator-driven-type-converters.md) — Provides automatic type conversion of property values to match TypeScript-declared types during transformation. ([source](https://cdn.jsdelivr.net/gh/typestack/class-transformer@develop/README.md))
- [Collection Element Transformations](https://awesome-repositories.com/f/data-databases/collection-element-transformations.md) — Converts elements inside arrays, Sets, and Maps into specified class types during transformation. ([source](https://cdn.jsdelivr.net/gh/typestack/class-transformer@develop/README.md))
- [Property Value Transformers](https://awesome-repositories.com/f/data-databases/file-storage-and-metadata-management/image-transformations/custom-transformation-pipelines/transform-logic-definitions/property-value-transformers.md) — Runs user-defined functions to modify property values during data conversion between plain objects and class instances. ([source](https://cdn.jsdelivr.net/gh/typestack/class-transformer@develop/README.md))
- [Property Name Mappings](https://awesome-repositories.com/f/data-databases/naming-conventions/property-name-mappings.md) — Maps a property to a different name in the transformed output during serialization or deserialization. ([source](https://cdn.jsdelivr.net/gh/typestack/class-transformer@develop/README.md))
- [Group-Based Property Filtering](https://awesome-repositories.com/f/data-databases/property-based-filtering/application-property-filters/group-based-property-filtering.md) — Includes or excludes properties based on assigned groups during transformation operations. ([source](https://cdn.jsdelivr.net/gh/typestack/class-transformer@develop/README.md))
- [Deep Class Instance Cloning](https://awesome-repositories.com/f/data-databases/zero-copy-cloning/deep-class-instance-cloning.md) — Provides deep cloning of class instances to create independent copies with preserved nested structures. ([source](https://cdn.jsdelivr.net/gh/typestack/class-transformer@develop/README.md))

### Networking & Communication

- [Class Instance Serializers](https://awesome-repositories.com/f/networking-communication/json-serialization/class-instance-serializers.md) — Converts class instances directly into JSON strings for storage or network transfer with decorator-driven rules. ([source](https://cdn.jsdelivr.net/gh/typestack/class-transformer@develop/README.md))

### Programming Languages & Runtimes

- [Decorator-Driven Property Transformers](https://awesome-repositories.com/f/programming-languages-runtimes/object-property-transformers/decorator-driven-property-transformers.md) — Applies custom conversion logic, renaming, and filtering to object properties during serialization or deserialization.
- [Object Property Transformers](https://awesome-repositories.com/f/programming-languages-runtimes/object-property-transformers.md) — Omits specified properties from the transformed output during object-to-class or class-to-object conversion. ([source](https://cdn.jsdelivr.net/gh/typestack/class-transformer@develop/README.md))

### Software Engineering & Architecture

- [Class Instance Deserializers](https://awesome-repositories.com/f/software-engineering-architecture/abstract-syntax-tree-tools/internal-tree-representations/json-deserializers/class-instance-deserializers.md) — Parses JSON strings into typed class instances with automatic type conversion and nested object handling. ([source](https://cdn.jsdelivr.net/gh/typestack/class-transformer@develop/README.md))
- [Typed Class Deserializers](https://awesome-repositories.com/f/software-engineering-architecture/abstract-syntax-tree-tools/internal-tree-representations/json-deserializers/typed-class-deserializers.md) — Parses JSON strings into typed class instances with automatic type conversion and nested object handling.
- [Nested Data Transformers](https://awesome-repositories.com/f/software-engineering-architecture/recursive-validation-engines/recursive-tree-traversers/data-structure-traversers/nested-data-transformers.md) — Recursively converts nested plain objects into their corresponding class instances using type metadata. ([source](https://cdn.jsdelivr.net/gh/typestack/class-transformer@develop/README.md))
- [Polymorphic Type Mapping](https://awesome-repositories.com/f/software-engineering-architecture/polymorphic-type-mapping.md) — Selects the correct subclass constructor for nested objects using a discriminator property during deserialization. ([source](https://cdn.jsdelivr.net/gh/typestack/class-transformer@develop/README.md))

### User Interface & Experience

- [Decorator-Driven Serializers](https://awesome-repositories.com/f/user-interface-experience/component-utilities/ui-frameworks/rendering-models/composition-rendering-patterns/component-patterns/class-components/class-decorators/decorator-driven-serializers.md) — Transforms class instances to plain objects and JSON strings with decorator-driven property mapping and exclusion rules.
- [Additional Property Filtering](https://awesome-repositories.com/f/user-interface-experience/component-property-systems/property-validation/additional-property-filtering.md) — Removes properties from a plain object that are not declared in the target class during transformation. ([source](https://cdn.jsdelivr.net/gh/typestack/class-transformer@develop/README.md))

### Development Tools & Productivity

- [Date String Parsers](https://awesome-repositories.com/f/development-tools-productivity/date-and-time-utilities/relative-date-formatting/date-string-parsers.md) — Automatically converts date strings within plain objects into JavaScript Date instances during transformation. ([source](https://cdn.jsdelivr.net/gh/typestack/class-transformer@develop/README.md))

### Security & Cryptography

- [Opt-In Property Exposure](https://awesome-repositories.com/f/security-cryptography/object-property-prohibitions/property-strictness/property-exclusion/opt-in-property-exposure.md) — Omits all class properties from transformation output unless they are explicitly marked for exposure. ([source](https://cdn.jsdelivr.net/gh/typestack/class-transformer@develop/README.md))

### Web Development

- [Getter and Method Result Exposure](https://awesome-repositories.com/f/web-development/computed-property-systems/getter-and-method-result-exposure.md) — Includes getter return values or method results in the transformed output during serialization. ([source](https://cdn.jsdelivr.net/gh/typestack/class-transformer@develop/README.md))
