COMPARISON · VALIDATION

@sinclair/typebox vs. class-validator

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

@sinclair/typebox v0.34.52 · MIT
Weekly Downloads
166.1M
Stars
15
Gzip Size
13.0 kB
License
MIT
Last Updated
9mo ago
Open Issues
5
Forks
1
Unpacked Size
1.9 MB
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
DOWNLOAD TRENDS

@sinclair/typebox vs class-validator downloads · last 12 months

Download trends for @sinclair/typebox and class-validator2 download series from Nov 2025 to Oct 2026. Use left and right arrow keys to inspect monthly values.0141.2M282.5M423.7M565.0MNov 2025FebMayAugOct 2026
@sinclair/typebox
class-validator
FEATURE COMPARISON

Criteria · @sinclair/typebox vs class-validator

Learning Curve
@sinclair/typebox
Requires familiarity with schema values and static type resolution
class-validator
Requires familiarity with class properties and decorators
Rule Placement
@sinclair/typebox
Rules are expressed in schema values
class-validator
Rules are attached to class properties with decorators
Adoption Signal
@sinclair/typebox ✓
Reported weekly downloads are higher
class-validator
Reported weekly downloads are lower
Validation Flow
@sinclair/typebox
Centers the flow on schema descriptions
class-validator
Centers the flow on classes carrying validation metadata
Bundle Footprint
@sinclair/typebox ✓
Reported gzip bundle is 13.0 kB
class-validator
Reported gzip bundle is 105.8 kB
Validation Model
@sinclair/typebox
Builds JSON Schema values that resolve to static TypeScript types
class-validator
Declares validation rules with decorators on class properties
Ecosystem Signals
@sinclair/typebox
Reported stars and forks are comparatively few
class-validator ✓
Has substantially more reported stars and forks
Schema Declaration
@sinclair/typebox
Schema-centered definitions serve as explicit data descriptions
class-validator
Validation declarations live on class properties
Data Contract Reuse
@sinclair/typebox ✓
Schema values provide explicit data descriptions to reuse
class-validator
Validation declarations remain associated with class definitions
Repository Issue Load
@sinclair/typebox ✓
Has 4 reported open issues
class-validator
Has 320 reported open issues
Installation Footprint
@sinclair/typebox ✓
Reported unpacked size is 1.9 MB
class-validator
Reported unpacked size is 5.3 MB
Class-Oriented Modeling
@sinclair/typebox
Does not center its stated model on decorated classes
class-validator ✓
Designed around validation of class properties
JSON Schema Orientation
@sinclair/typebox ✓
Explicitly focused on building JSON Schema
class-validator
Uses property decorators rather than a schema-builder model
TypeScript Type Alignment
@sinclair/typebox ✓
Static types are resolved from the JSON Schema builder
class-validator
Works through a class-and-decorator validation model
VERDICT

@sinclair/typebox is designed for TypeScript developers who want to define JSON Schema values in code and obtain corresponding static TypeScript types. Its schema-first approach suits applications that need a single description of data to support both compile-time typing and runtime validation, rather than class instances as the center of the model. The package’s stated focus is building JSON Schema with static type resolution, making it a natural fit when schemas are also part of an application’s data contract.

class-validator is aimed at developers who model their data as classes and want validation rules attached to class properties through decorators. That approach places validation close to object definitions and aligns with codebases whose validation flow already starts from class-shaped input. It is a distinct choice from @sinclair/typebox: the primary abstraction is decorated class properties, not JSON Schema values that resolve to static types.

The key architectural difference is how validation rules are represented and consumed. With @sinclair/typebox, the central artifact is a schema value, which can serve as an explicit description of data and its TypeScript type; with class-validator, metadata is expressed through decorators on class properties and validation is organized around those classes. Prefer the former when schemas themselves are useful application artifacts, and the latter when class definitions should carry the validation declarations.

This difference also affects extension and reuse. @sinclair/typebox’s JSON Schema orientation gives teams a schema-centered way to compose or share data descriptions across code that consumes those schemas, while class-validator’s decorator model encourages rules to remain associated with the class properties they annotate. The supplied package information does not establish particular plugin systems or interoperability features, so the choice should rest on whether a schema artifact or decorated class is the more appropriate unit of reuse.

The developer experience trade-off follows the same divide. @sinclair/typebox combines schema construction with static type resolution, which can reduce the conceptual gap between a runtime data description and its TypeScript type, though developers must be comfortable working with schema values. class-validator’s property decorators can feel direct in a class-oriented codebase, but its validation declarations are tied to understanding the class and decorator model; teams choosing it should decide whether that representation fits their data flow.

The provided size figures make @sinclair/typebox the more compact option for a project where package footprint matters: its reported gzip bundle is 13.0 kB, compared with 105.8 kB for class-validator, and its unpacked size is 1.9 MB rather than 5.3 MB. These measurements are a useful comparison, not a complete prediction of an application’s final output or runtime speed. The data does not provide execution benchmarks, so it would be unsupported to conclude that either package validates faster.

Choose @sinclair/typebox when JSON Schema is central to your data contracts, when you want schema definitions to resolve to static TypeScript types, or when a smaller reported bundle is important. Choose class-validator when your application already expresses data as classes and you prefer property-level decorators to declare validation rules. In either case, align the package with the representation used by the rest of the application rather than selecting solely on download or repository figures.

The available figures show different repository signals: @sinclair/typebox has 4 open issues, while class-validator has 320, and class-validator has substantially more reported stars and forks. Those counts describe the supplied snapshot; they do not establish issue severity, response time, or future maintenance. For long-term adoption, evaluate how naturally the schema-centered or decorator-centered model fits existing code, because changing that model later can require revisiting where validation rules live and how data definitions are shared.

A practical edge case is a project that needs both class-shaped application objects and explicit JSON Schema contracts: the two packages represent those concerns differently, so adopting either as the sole source of truth may require a deliberate boundary between the representations. For a schema-led service or library, @sinclair/typebox keeps the schema as the primary declaration; for a class-led application, class-validator keeps property decorators as the primary declaration. Decide which form should own validation rules before introducing either package across a large set of data models.

CORRECTIONS

Spot wrong data here?

A short note helps us fix it.

Anonymous · No account · No email back

RELATED COMPARISONS 8
@sinclair/typebox vs joi ★ 21.2K · 199.6M/wk @sinclair/typebox vs valibot ★ 9.1K · 201.1M/wk @sinclair/typebox vs superstruct ★ 7.1K · 175.8M/wk @sinclair/typebox vs zod ★ 44.4K · 628.9M/wk @sinclair/typebox vs ow ★ 3.9K · 168.7M/wk @sinclair/typebox vs fast-xml-parser ★ 3.2K · 280.7M/wk @sinclair/typebox vs ajv ★ 14.9K · 701.2M/wk @sinclair/typebox vs yup ★ 23.7K · 182.4M/wk