JavaScript data validation libraries

Data validation libraries are designed for validating data at runtime, so it throws or returns detailed runtime errors for you or your end users. This is especially useful in situations like accepting arbitrary input in a REST or GraphQL API. It can even be used to validate internal data structures at runtime when needed.

Editor's Picks

image

Joi

The most powerful schema description language and data validator for JavaScript. Joi lets you describe your data using a simple, intuitive, and readable language.
image

Validator.js

This library validates and sanitizes strings only, validate all sorts of concerns related to string and convert if possible.
image

Yup

Yup is a JavaScript schema builder for value parsing and validation, heavily inspired by Joi, but leaner and built with client-side validation as its primary use-case.
image

Ajv

Ajv is a JSON Schema validator for Node.js and browser, implements full JSON Schema, asynchronous loading of referenced schemas during compilation, etc.
image

Superstruct

Superstruct makes it easy to define interfaces and then validate JavaScript data against them. Its type annotation API was inspired by Typescript, Flow, Go, and GraphQL, giving it a familiar and easy to understand API.