API Reference

class-transformer

Transforms plain objects into typed class instances and back, with Type and Transform decorators.

Official Documentation ↗
CompatibilityThis documentation covers version v0.5. Check the official docs for the latest API surface.

Installation

npmnpm install class-transformer

Methods

class-transformer bridges JSON payloads and class instances so methods and types are available after parsing.

Key Features

  • plainToInstance and instanceToPlain
  • Type and Transform decorators
  • Exclude and expose strategies

Usage Notes

Pin a version and check the official docs for the API surface you depend on before upgrading.

API reference evidence

Fetched from official sources on 2026-11-08T09:38:08.940Z via WebFetch https://raw.githubusercontent.com/typestack/class-transformer/master/src/index.ts; WebFetch https://raw.githubusercontent.com/typestack/class-transformer/master/src/decorators/type.decorator.ts.

FAQ

Why are nested objects still plain?
The transformer can only instantiate classes it knows about. Add @Type(() => Child) to nested properties so they are converted too.
How do I exclude sensitive fields?
Use @Exclude() together with excludeExtraneousValues or explicit @Expose() annotations so only intended fields are serialized.
Does it validate values?
No. It converts shapes only. Combine it with class-validator when you need constraint checking.