COMPARISON · VALIDATION

class-validator vs. superstruct

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
superstruct v2.0.2 · MIT
Weekly Downloads
9.8M
Stars
7.1K
Gzip Size
3.5 kB
License
MIT
Last Updated
2y ago
Open Issues
111
Forks
225
Unpacked Size
182.3 kB
Dependencies
1
DOWNLOAD TRENDS

class-validator vs superstruct downloads · last 12 months

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

Criteria · class-validator vs superstruct

Learning Curve
class-validator
Requires familiarity with decorators and class-instance validation
superstruct
Requires learning its structure-based validation declarations
Migration Effort
class-validator
Requires converting structure definitions into property decorators
superstruct
Requires translating class-property rules into structures
Validation Model
class-validator
Applies constraints to class properties and validates instances
superstruct
Validates data against declared structures
Adoption Evidence
class-validator ✓
Higher downloads, stars, and forks in the supplied data
superstruct
Lower downloads, stars, and forks in the supplied data
Package Footprint
class-validator
Larger distribution footprint at 105.8 kB gzip
superstruct ✓
Compact distribution footprint at 3.5 kB gzip
Schema Declaration
class-validator
Rules are declared with decorators on class fields
superstruct
Validation shapes are declared separately as structures
TypeScript Workflow
class-validator
TypeScript validation centered on decorated classes
superstruct
TypeScript validation centered on declared structures
Class-Based Modeling
class-validator ✓
Fits validation rules attached to application classes
superstruct
Keeps validation independent of class declarations
Composition of Rules
class-validator
Organizes constraints around decorated class properties
superstruct ✓
Supports a composable structure-oriented approach
Decorator Dependency
class-validator
Uses decorators as its defining declaration style
superstruct ✓
Does not require decorator-based declarations
Repository Issue Load
class-validator
320 open issues in the supplied data
superstruct ✓
109 open issues in the supplied data
Plain Object Validation
class-validator
Class-instance-oriented validation model
superstruct ✓
Directly suited to JavaScript and TypeScript data structures
Validation Organization
class-validator
Keeps rules alongside class property definitions
superstruct
Keeps schemas distinct from the data being checked
JavaScript Applicability
class-validator
Described as decorator-based property validation for classes
superstruct ✓
Explicitly targets JavaScript as well as TypeScript
VERDICT

class-validator is best suited to TypeScript applications whose data is already represented as class instances and whose validation rules belong alongside class properties. Its decorator-based approach makes validation declarations part of the class model, which can fit teams that prefer annotated objects over separate schema definitions. The adoption figures also show a larger existing user base than superstruct, although that alone does not determine which API fits a project.

superstruct is aimed at JavaScript and TypeScript code that wants validation expressed through composable data structures rather than decorators on classes. Its schema-oriented approach is a natural fit when data arrives as plain objects and the validation shape should be defined independently of a class declaration. That distinction can make superstruct useful in codebases that do not model incoming data as class instances.

The central architectural difference is where validation rules live and how data flows through them. With class-validator, developers declare constraints on class properties and validate instances; with superstruct, developers describe a structure and validate data against it. Choosing between them therefore affects how schemas are organized, how objects are represented, and whether validation is coupled to application classes.

Their extension styles follow those same foundations. class-validator offers decorator-oriented declarations that keep property rules visible at the class definition, which is convenient when each rule maps directly to a field. superstruct emphasizes composing structures, making validation logic easier to organize as reusable schema pieces when the same shape or nested structure appears in multiple places; the provided package details do not specify a separate plugin model for either.

For developer experience, class-validator is a closer fit for teams already comfortable with TypeScript classes and decorators, but that style requires validation to be read in the context of class definitions. superstruct keeps schemas explicit and separate from data objects, which can make the validation contract easier to inspect without class-based modeling. Both descriptions identify TypeScript support, while superstruct also explicitly targets JavaScript, so it is the more direct choice when validation must not depend on TypeScript class syntax.

The clearest operational difference is distribution footprint: superstruct is 3.5 kB gzipped, compared with 105.8 kB for class-validator, and its unpacked size is 182.3 kB rather than 5.3 MB. For client-facing code, constrained deployments, or applications where dependency weight matters, that gap may influence the decision; it does not by itself establish runtime validation speed. If bundle size is secondary to class-oriented validation, class-validator remains a viable choice.

Choose class-validator when the application already uses class instances, property decorators suit its coding conventions, and validation rules should live next to those properties. Choose superstruct when data is primarily plain JavaScript or TypeScript objects, schemas should be composed or kept separate from classes, or minimizing shipped package weight is important. Its lower open-issue count is an additional maintenance signal in the supplied data, while class-validator has higher downloads, stars, and forks; neither set of counts proves which implementation will better fit a particular team.

Migration is not a mechanical swap because the packages organize validation differently: moving from class-validator to superstruct means expressing class-property constraints as structure definitions, while moving in the other direction means attaching rules to class properties and validating instances. A team should inventory its data shapes and validation call sites before switching, especially if validation currently depends on class instances. The supplied information does not establish interoperability or a migration utility, so plan for deliberate rule translation rather than assuming one.

A useful boundary case is a codebase that mixes class-based domain objects with plain incoming payloads. class-validator aligns naturally with the former, whereas superstruct can validate the latter without requiring class-shaped data; the right choice depends on which representation is authoritative at the validation boundary. For teams weighing long-term adoption, class-validator's stronger usage and repository counts may provide a larger visible community, while superstruct's smaller footprint and fewer open issues may be more attractive when simplicity and compact delivery dominate.

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 yup ★ 35.5K · 34.3M/wk class-validator vs valibot ★ 21.0K · 53.0M/wk