COMPARISON · VALIDATION

ajv vs. yup

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

ajv v8.20.0 · MIT
Weekly Downloads
535.1M
Stars
14.9K
Gzip Size
36.1 kB
License
MIT
Last Updated
9mo ago
Open Issues
411
Forks
1.1K
Unpacked Size
1.0 MB
Dependencies
4
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

ajv vs yup downloads · last 12 months

Download trends for ajv and yup2 download series from Nov 2025 to Oct 2026. Use left and right arrow keys to inspect monthly values.0461.9M923.9M1385.8M1847.8MNov 2025FebMayAugOct 2026
ajv
yup
FEATURE COMPARISON

Criteria · ajv vs yup

Npm Usage
ajv ✓
159.4M weekly downloads in the supplied data
yup
4.3M weekly downloads in the supplied data
Learning Curve
ajv
Requires familiarity with JSON Schema concepts
yup
Requires familiarity with yup’s object-schema conventions
Extension Approach
ajv
Extends validation around JSON Schema conventions
yup
Extends validation through its schema-building API
Schema Declaration
ajv
Defines validation rules as JSON Schema data
yup
Builds object schemas through its own API
TypeScript Evidence
ajv
Comparative TypeScript details are not provided
yup
Comparative TypeScript details are not provided
Contract Portability
ajv ✓
Well aligned with contracts represented as JSON Schema
yup
Schema rules are expressed in yup’s API
Reported Issue Count
ajv
390 open issues in the supplied data
yup ✓
267 open issues in the supplied data
Installation Footprint
ajv
Larger unpacked package at 1.0 MB
yup ✓
Smaller unpacked package at 270.4 kB
Browser Bundle Footprint
ajv
Larger supplied gzip bundle at 36.1 kB
yup ✓
Smaller supplied gzip bundle at 14.2 kB
Validation Error Workflow
ajv
Validation is organized around a schema and its result
yup
Validation is organized around yup-defined object schemas
Code-First Object Validation
ajv
Uses a specification-centered schema workflow
yup ✓
Focused on direct object-schema validation
Runtime Performance Evidence
ajv
No comparative benchmark data supplied
yup
No comparative benchmark data supplied
Schema Reuse Across Services
ajv ✓
Suitable when services share JSON Schema contracts
yup
Suited to schemas authored within application code
Use of JSON Schema Contracts
ajv ✓
Directly based on JSON Schema validation
yup
Uses yup’s own object-schema model
Migration Between Schema Models
ajv
Requires translating yup rules into JSON Schema
yup
Requires translating JSON Schema rules into yup expressions
VERDICT

ajv is oriented around validating data against JSON Schema, making it a strong fit when schemas are formal contracts shared across services, stored as data, or used to check externally supplied JSON. Its core philosophy is standards-based validation: define the expected shape and constraints in a schema, then ask ajv to test values against that specification. This approach suits teams that need explicit, portable rules rather than schemas expressed chiefly as application code. Its 159.4M weekly downloads also indicate substantially greater npm usage than yup, though downloads alone do not establish suitability for a particular project.

yup is designed for object-schema validation with a direct, code-first style. Its stated focus on being a “Dead simple Object schema validation” package makes it a natural option when developers want to describe application data constraints through yup’s own schema-building API rather than begin with a JSON Schema document. The 23.7K GitHub stars, compared with ajv’s 14.9K, show that yup has more stars in the supplied data, but that difference does not change the distinction in their primary schema models.

The central architectural difference is how a schema is represented and consumed. With ajv, the schema is JSON Schema data and validation is performed against that specification; with yup, the schema is constructed through an object-oriented validation API and used to check values. This affects where rules live: ajv can keep a contract in a structured schema document, while yup encourages developers to express validation alongside application code. Choose the representation that matches how your project authors, reviews, and exchanges its data contracts.

Their extension approaches also follow those different models. ajv extends validation around JSON Schema’s vocabulary and supports a specification-centered workflow, which is useful when constraints need to remain legible as schema data and align with a shared contract. yup’s extension point is its schema-building style, which keeps validation rules within the same fluent object-schema expression. These are not interchangeable authoring conventions: a team moving between them may need to redesign how rules are represented, not merely rename equivalent functions.

The developer experience trade-off is between a standards-shaped schema and a code-shaped schema. ajv asks developers to understand JSON Schema concepts and the relationship between a schema and the data it validates; in return, the contract is explicit and separate from the validation call. yup keeps object validation close to its API, which can be straightforward for developers who prefer to build constraints in code, but requires familiarity with yup’s schema conventions. The supplied information does not establish a comparative TypeScript feature set, so TypeScript support should be evaluated against the versions and type requirements of the intended project rather than inferred from these package figures.

For payload size, yup has the clear advantage in the supplied figures: its gzip bundle is 14.2 kB, versus 36.1 kB for ajv, and its unpacked size is 270.4 kB versus 1.0 MB. That difference can matter when a validator is included in a browser-facing bundle or when installation footprint is a constraint. Bundle size alone does not prove runtime speed, and the data provided does not include benchmarks, so it would be inaccurate to claim that either package validates faster. Assess performance with representative schemas and inputs if throughput is a deciding requirement.

Pick ajv when JSON Schema is already the contract format, when schemas need to be reviewed or exchanged independently of application code, or when a project values the broad usage reflected by its 159.4M weekly downloads. Pick yup when the work centers on validating application objects through a code-first schema API and the smaller supplied package footprint is useful. For a small frontend form, yup’s compact bundle and direct object-schema model may be a practical fit; for a service validating structured JSON against a shared schema, ajv’s contract-centered model may reduce friction. The better choice follows the data model and delivery context, not a single popularity metric.

Migration between ajv and yup is not usually a mechanical replacement because the schema languages and authoring styles differ. Moving from ajv to yup means translating JSON Schema constraints into yup schema expressions; moving from yup to ajv means expressing code-defined rules as JSON Schema where the target format supports the required constraints. Review custom validation behavior and error handling during that translation, and test representative valid and invalid values. The supplied issue counts are lower for yup (267 versus ajv’s 390), but issue counts by themselves do not establish maintenance quality or predict migration effort.

A useful edge-case distinction is whether validation rules need to travel as schema data. If schemas are exchanged, persisted, or treated as an explicit interface contract, ajv’s JSON Schema foundation is directly aligned with that requirement. If rules are private to an application’s object-processing flow and developers prefer to compose them in code, yup’s API-centered model may be easier to maintain. The supplied data does not establish support for particular schema drafts, specialized validation features, or current release plans, so verify those requirements against the exact versions before adopting either package for a specialized use case.

CORRECTIONS

Spot wrong data here?

A short note helps us fix it.

Anonymous · No account · No email back

RELATED COMPARISONS 8
ajv vs valibot ★ 24.0K · 570.2M/wk ajv vs joi ★ 36.1K · 568.7M/wk ajv vs class-validator ★ 26.7K · 553.1M/wk ajv vs zod ★ 59.3K · 997.9M/wk ajv vs superstruct ★ 22.0K · 544.9M/wk ajv vs fast-xml-parser ★ 18.0K · 649.7M/wk @sinclair/typebox vs ajv ★ 14.9K · 701.2M/wk ajv vs ow ★ 18.7K · 537.8M/wk