PACKAGE · VALIDATION

yup

Dead simple Object schema validation

WEEKLY DOWNLOADS 5.7M
STARS 23.7K
FORKS 939
OPEN ISSUES 241
GZIP SIZE 14.2 kB
UNPACKED SIZE 270.4 kB
DEPENDENCIES 4
LAST UPDATED 8mo ago
DOWNLOAD TRENDS

yup downloads — last 12 months

Download trends for yup1 download series from Jun 2025 to May 2026. Use left and right arrow keys to inspect monthly values.011.9M23.8M35.8M47.7MJun 2025SepDecMarMay 2026
yup
ABOUT YUP

Yup is a JavaScript schema builder for value validation and type casting. It addresses the common need for robust data validation in applications, particularly for incoming data from user interfaces, APIs, or configuration files. By defining expected data shapes and rules, Yup helps prevent runtime errors and ensures data integrity.

The core philosophy behind Yup is to provide a declarative and intuitive way to define schemas. It aims to be a developer-friendly tool, enabling the creation of complex validation logic with minimal boilerplate. This makes it suitable for developers working with dynamic data where strict type enforcement is crucial.

Key API patterns include the fluent interface for building schemas, such as `object().shape()`, `string().email()`, and `number().min()`. Yup supports various data types and a wide range of validation methods like required fields, email formats, min/max values, and custom validation functions. The `validate()` and `validateSync()` methods are central to its usage for checking data against a defined schema.

Yup integrates seamlessly into various JavaScript environments and workflows. It's commonly used in front-end frameworks like React and Vue for form validation, and in Node.js back-ends for validating API request bodies. It pairs well with serialization libraries and can be used within build pipelines or testing frameworks to ensure data consistency.

With a substantial weekly download count of 9.5 million and 23.7K GitHub stars, Yup is a mature and widely adopted library. Its unpacked size is 270.4 kB, with a gzipped bundle size of just 14.2 kB, indicating a relatively lean footprint for its capabilities.

While powerful, Yup's primary focus is on object schema validation. For highly specialized or extremely performance-critical validation scenarios that do not involve complex object structures, developers might explore alternative, more specialized libraries. Its extensibility is generally good, but complex custom logic may require careful implementation.

WHEN TO USE
  • When validating form input data in React, Vue, or Angular applications using `object().shape()` to define field requirements and formats.
  • When ensuring data integrity for API request payloads in Node.js environments by defining schemas with `string().email()` or `number().positive()`.
  • When performing type casting and validation of configuration files before application startup.
  • When creating reusable validation logic for different parts of an application or across multiple projects.
  • When leveraging its fluent API to build complex validation rules, such as nested objects and array validations with `array().of()`.
  • When you need to validate data against a predefined schema before processing it further in asynchronous operations using `validate()`.
WHEN NOT TO USE
  • If you only need to check for the existence of a value, JavaScript's truthiness check (`if (value)`) is sufficient and avoids an additional dependency.
  • If your validation needs are limited to simple primitive type checks without complex rules, consider native JavaScript type checking or a more specialized, lighter validation utility.
  • When dealing with highly specialized binary data formats where byte-level validation is required, as Yup is optimized for JSON-like structures.
  • If you are working in an environment with extremely strict Content Security Policy (CSP) limitations that might interfere with dynamic schema evaluation, although common use cases are generally fine.
  • When you need to validate data structures that are inherently deeply recursive or violate typical object graph limitations, which could lead to performance issues with `validate()`.

CORRECTIONS

Spot wrong data here?

A short note helps us fix it.

Anonymous · No account · No email back

COMPARISONS 9
yup vs fast-xml-parser ★ 3.1K · 40.1M/wk yup vs zod ★ 42.9K · 94.7M/wk yup vs @sinclair/typebox ★ 8 · 47.8M/wk yup vs valibot ★ 8.7K · 5.8M/wk yup vs superstruct ★ 7.1K · 2.6M/wk yup vs ow ★ 3.9K · 1.2M/wk yup vs ajv ★ 14.7K · 153.1M/wk yup vs joi ★ 21.2K · 10.1M/wk yup vs class-validator ★ 11.8K · 4.5M/wk