COMPARISON · VALIDATION

class-validator vs. yup

Side-by-side comparison · 9 metrics · 14 criteria

class-validator v0.15.1 · MIT
Weekly Downloads
18.0M
Stars
11.9K
Gzip Size
105.8 kB
License
MIT
Last Updated
9mo ago
Open Issues
329
Forks
848
Unpacked Size
5.3 MB
Dependencies
N/A
yup v1.7.1 · MIT
Weekly Downloads
16.4M
Stars
23.6K
Gzip Size
14.2 kB
License
MIT
Last Updated
1y ago
Open Issues
274
Forks
960
Unpacked Size
270.4 kB
Dependencies
4
DOWNLOAD TRENDS

class-validator vs yup downloads · last 12 months

Download trends for class-validator and yup2 download series from Nov 2025 to Oct 2026. Use left and right arrow keys to inspect monthly values.014.8M29.6M44.3M59.1MNov 2025FebMayAugOct 2026
class-validator
yup
FEATURE COMPARISON

Criteria · class-validator vs yup

Schema Reuse
class-validator
Reuse is organized around decorated classes
yup ✓
Schemas are explicit artifacts that can be reused by validation code
Learning Curve
class-validator
Requires familiarity with decorator-based class declarations
yup
Requires familiarity with schema declaration syntax
Model Coupling
class-validator
Validation rules are coupled to the class model
yup
Validation rules can remain separate from the data representation
Rule Placement
class-validator
Constraints sit beside the corresponding class fields
yup
Rules are grouped in a schema definition
Adoption Signal
class-validator
Higher weekly downloads at 4.6M
yup
Lower weekly downloads at 4.3M, but more stars and forks
Migration Shape
class-validator
Moving to it requires class declarations and property decorators
yup
Moving to it requires translating rules into object schemas
Issue Backlog Signal
class-validator
320 open issues reported
yup ✓
267 open issues reported
Client Bundle Footprint
class-validator
Reported gzip bundle is 105.8 kB
yup ✓
Reported gzip bundle is 14.2 kB
Fit for Class-Based Models
class-validator ✓
Direct fit when domain data is represented as classes
yup
Schemas are separate from class declarations
Installed Package Footprint
class-validator
Reported unpacked size is 5.3 MB
yup ✓
Reported unpacked size is 270.4 kB
Validation Declaration Model
class-validator
Attaches validation rules to class properties with decorators
yup
Defines validation rules in explicit object schemas
Fit for Plain Object Validation
class-validator
Validation is organized around class instances
yup ✓
Object schemas directly describe the data shape
Separation of Data and Validation
class-validator
Validation annotations are coupled to class declarations
yup ✓
Schema rules can be maintained apart from runtime objects
TypeScript and Decorator Orientation
class-validator ✓
Explicitly oriented around TypeScript classes and decorators
yup
The supplied description emphasizes object schemas, not decorators
VERDICT

class-validator is suited to TypeScript applications that define domain objects as classes and want validation rules attached directly to their properties. Its decorator-based philosophy keeps constraints close to the class fields they describe, which can work well when classes already represent application data and validation should follow those models. Its audience is developers who prefer class-oriented declarations over maintaining separate object schemas.

yup is suited to applications that describe valid data with explicit object schemas rather than decorating class properties. Its “Dead simple Object schema validation” positioning aligns with validating plain data shapes and keeping the definition of a shape in one schema. This makes yup a natural fit when data enters as objects and the validation rules should be expressed independently of class instances.

The central architectural difference is where each package stores its rules and how validation is organized. With class-validator, rules are declared as decorators on class members, so validation is associated with a class and its properties; with yup, the developer builds a schema that describes the object being checked. That distinction affects how models are shared: class-validator couples constraints to class declarations, while yup keeps the schema as a separate, explicit artifact that can be passed to validation code.

Their declaration styles also create different extension and composition patterns. In class-validator, adding a property constraint means annotating the relevant class member, keeping the rule visible beside that field but requiring the class to be part of the design. In yup, adding or changing a rule means editing the schema definition, which allows a validation shape to be maintained apart from the data’s runtime representation. Choose based on whether class-centered rule placement or standalone schema composition better matches the way your application organizes data contracts.

The developer experience follows the same divide. Developers comfortable with TypeScript classes and decorators may find class-validator’s field-by-field declarations easy to locate, while teams unfamiliar with decorator-based models must learn to read and maintain those annotations. yup asks developers to learn its schema declaration style instead; this can be direct for object validation, though it means keeping schema definitions and the types or objects they describe aligned. The supplied package information identifies class-validator with TypeScript and decorators, but does not establish a comparative advantage in type inference or editor tooling.

For shipped footprint, yup has a clear advantage in the supplied figures: its reported gzip bundle size is 14.2 kB, compared with 105.8 kB for class-validator, and its unpacked size is 270.4 kB rather than 5.3 MB. If client-side delivery or installed package footprint is a constraint, that difference is relevant when comparing these versions. The figures alone do not establish runtime validation speed, so performance-sensitive selection should not treat smaller package size as proof that yup validates data faster.

Choose class-validator when your application already models validated data as classes and you want constraints declared at the property level; its slightly higher weekly downloads may also matter when matching an existing team convention, though downloads alone do not determine fit. Choose yup when your input is naturally represented as plain objects, you want validation rules expressed as schemas, or you need to minimize the supplied bundle footprint. For a form or API boundary, decide first whether the class itself or a separately declared schema should be the source of validation rules, then compare how that choice fits the surrounding code.

The reported ecosystem signals are mixed rather than a substitute for architectural fit: class-validator has more weekly downloads, while yup has more stars and forks and fewer open issues. Those figures describe different forms of activity and do not prove which package is more suitable for a particular codebase. Before adopting either, review the project’s required validation cases and the package’s current documentation; the provided data does not specify feature coverage, release cadence beyond the supplied dates, or migration tooling.

Migration between the two is not simply a change of import because the declarations themselves have different shapes. Moving from class-validator to yup entails translating property-level decorators into schema rules and deciding where those schemas belong; moving the other way entails introducing classes and attaching constraints to their fields. If a codebase relies on classes as its data contract, class-validator avoids a separate schema layer, while yup can be easier to keep focused on object validation when those classes are absent.

CORRECTIONS

Spot wrong data here?

A short note helps us fix it.

Anonymous · No account · No email back

RELATED COMPARISONS 8
ajv vs class-validator ★ 26.7K · 553.1M/wk class-validator vs joi ★ 33.0K · 51.6M/wk class-validator vs ow ★ 15.7K · 20.6M/wk @sinclair/typebox vs class-validator ★ 11.9K · 184.0M/wk class-validator vs zod ★ 56.3K · 480.8M/wk class-validator vs fast-xml-parser ★ 15.0K · 132.6M/wk class-validator vs valibot ★ 21.0K · 53.0M/wk class-validator vs superstruct ★ 19.0K · 27.7M/wk