# JavaScript validation libraries

JavaScript validation libraries check that incoming data, such as a request body or a form submission, has the shape and values an app expects. These libraries let APIs and AI agents reject malformed input before it reaches application code, including the arguments a language model passes to a tool.

## Popularity

| Library | Monthly downloads | Stars | Last release | License |
| --- | --- | --- | --- | --- |
| [Ajv](#ajv) | 2.0B | 14.9K | Apr 2026 | MIT |
| [Zod](#zod) | 1.8B | 44.3K | Oct 2026 | MIT |
| [Effect](#effect) | 271.4M | 17.6K | Nov 2026 | MIT |
| [validator.js](#validator) | 137.1M | 23.7K | Apr 2026 | MIT |
| [Joi](#joi) | 132.0M | 21.2K | Nov 2026 | BSD-3-Clause |
| [Valibot](#valibot) | 126.5M | 9.1K | Sep 2026 | MIT |
| [class-validator](#class-validator) | 67.3M | 11.9K | Feb 2026 | MIT |
| [TypeBox](#typebox) | 65.2M | 7.0K | Nov 2026 | MIT |

Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

[Ajv](#ajv) has the most monthly downloads in this comparison, at 2.0B.

## Capabilities

| Library | Object schemas | Async checks | Input conversion |
| --- | --- | --- | --- |
| [Ajv](#ajv) | Yes | Yes | Yes |
| [Zod](#zod) | Yes | Yes | Yes |
| [Effect](#effect) | Yes | Yes | Yes |
| [validator.js](#validator) | No | No | Yes |
| [Joi](#joi) | Yes | Yes | Yes |
| [Valibot](#valibot) | Yes | Yes | Yes |
| [class-validator](#class-validator) | Yes | Yes | Via plugin |
| [TypeBox](#typebox) | Yes | No | Yes |

## Libraries

### Ajv

[GitHub](https://github.com/ajv-validator/ajv) · [npm](https://www.npmjs.com/package/ajv) · [Docs](https://ajv.js.org/guide/getting-started.html)

Ajv validates data against JSON Schema and JSON Type Definition schemas in Node.js and browsers. `ajv.compile` turns a schema into a validation function and caches it, so the same schema object is never compiled twice. The function returns true or false and stores any problems in its `errors` property, with an option to collect every error instead of stopping at the first. Options can also remove extra properties, fill in default values, and coerce values to the types a schema declares. Formats such as email and date come from a separate plugin, ajv-formats.

- Downloads / mo: 2.0B
- Stars: 14.9K
- Last release: 8.20.0
- License: MIT
- Capabilities: [From the Ajv docs](https://ajv.js.org/guide/getting-started.html)

**Strengths**

- **Reuses compiled schema validators.** Compiles a schema once and reuses its validation function.
- **Supports asynchronous custom checks.** Async formats and keywords handle checks that call a database or another service.

**Watch out for**

- **Coercion changes object properties.** With coercion on, Ajv changes properties of the validated object in place.
- **Standard formats need a plugin.** Formats such as email and date come from the ajv-formats plugin.

```sh
npm install ajv@8.20.0
```

**webpack/schema-utils** (253 stars)

[webpack/schema-utils](https://github.com/webpack/schema-utils) 

```javascript
function validateObject(schema, options) {
  // Not need to cache, because `ajv@8` has built-in cache
  const compiledSchema = getAjv().compile(schema);
  const valid = compiledSchema(options);

  if (valid) return [];

  return compiledSchema.errors ? filterErrors(compiledSchema.errors) : [];
}
```

[src/validate.js](https://github.com/webpack/schema-utils/blob/a6bbb4e41666378e5dfab81c45c335ccf7aa7bb6/src/validate.js#L443-L451) · [More projects using Ajv →](https://dashboard.exa.ai/playground/search?q=JavaScript%20projects%20that%20use%20ajv&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```javascript
const Ajv = require("ajv")
const ajv = new Ajv() // options can be passed, e.g. {allErrors: true}

const schema = {
  type: "object",
  properties: {
    foo: {type: "integer"},
    bar: {type: "string"}
  },
  required: ["foo"],
  additionalProperties: false
}

const validate = ajv.compile(schema)

const data = {
  foo: 1,
  bar: "abc"
}

const valid = validate(data)
if (!valid) console.log(validate.errors)

```

From [getting-started.md](https://github.com/ajv-validator/ajv/blob/master/docs/guide/getting-started.md)

### Zod

[GitHub](https://github.com/colinhacks/zod) · [npm](https://www.npmjs.com/package/zod) · [Docs](https://cdn.jsdelivr.net/npm/zod@4.6.7/README.md)

Zod is a TypeScript-first validation library with no external dependencies. A schema such as `z.object` describes the data, and `.parse` checks an input against it and returns a typed deep copy when the input is valid. The TypeScript type comes from the same schema, so the type and the runtime check can't drift apart. Refinements add custom checks, `.parseAsync` runs asynchronous ones, and `z.toJSONSchema` exports a schema to JSON Schema. For hot paths, `z.compile` builds a faster version of a schema ahead of time.

- Downloads / mo: 1.8B
- Stars: 44.3K
- Last release: 4.6.7
- License: MIT
- Capabilities: [From the Zod docs](https://cdn.jsdelivr.net/npm/zod@4.6.7/README.md)

**Strengths**

- **Adds custom validation rules.** Refinements add checks the built-in schema methods don't cover.
- **Converts schemas to JSON Schema.** z.toJSONSchema exports a schema to JSON Schema.

**Watch out for**

- **Async refinements need async parsing.** A schema with async refinements needs parseAsync, or Zod throws.
- **Some types don't convert.** Types with no JSON Schema equivalent can't be represented.

```sh
npm install zod@4.6.7
```

**react-hook-form/resolvers** (2.3K stars)

[react-hook-form/resolvers](https://github.com/react-hook-form/resolvers) 

```typescript
export function zodResolver<Input extends FieldValues, Context, Output>(
  schema: object,
  schemaOptions?: object,
  resolverOptions: {
    mode?: 'async' | 'sync';
    raw?: boolean;
  } = {},
): Resolver<Input, Context, Output | Input> {
  // Zod 4 is checked first: its `_zod` marker is unambiguous, whereas the
  // Zod 3 check below only requires an object-shaped `_def` (to support
  // dynamically-selected schemas typed via the generic `z.ZodType<Output>`
  // annotation, see `isZod3Schema`) — and Zod 4 schemas also have an
  // object-shaped `_def`, so they'd otherwise be misdetected as Zod 3.
  if (isZod4Schema(schema)) {
    return async (values: Input, _, options) => {
      try {
        // Call the schema's own bound `parse`/`parseAsync` method rather
        // than the standalone `z4.parse`/`z4.parseAsync` functions. Those
        // standalone functions read from this module's own imported
        // `zod/v4/core`, which — under bundlers that can resolve `zod` and
        // `zod/v4/core` to two distinct module instances (e.g. Metro with
        // package-exports resolution enabled) — may not be the same zod
        // instance the schema was created with, silently dropping any
        // global config (`z.config()`) or locale the app configured on its
        // own zod instance. The schema's own method is always bound to
        // whichever zod instance actually created it.
        const classicSchema = schema as unknown as {
          parse: (values: unknown, schemaOptions: unknown) => unknown;
          parseAsync: (
            values: unknown,
            schemaOptions: unknown,
          ) => Promise<unknown>;
        };
        const data: any =
          resolverOptions.mode === 'sync'
            ? classicSchema.parse(values, schemaOptions)
            : await classicSchema.parseAsync(values, schemaOptions);

        options.shouldUseNativeValidation &&
          validateFieldsNatively({}, options);

        return {
          errors: {},
          values: resolverOptions.raw ? Object.assign({}, values) : data,
        } satisfies ResolverSuccess<Output | Input>;
      } catch (error) {
        if (isZod4Error(error)) {
          return {
            values: {},
            errors: toNestErrors(
              parseZod4Issues(
                error.issues,
                !options.shouldUseNativeValidation &&
                  options.criteriaMode === 'all',
              ),
              options,
            ),
          } satisfies ResolverError<Input>;
        }

        throw error;
      }
    };
  }

  if (isZod3Schema(schema)) {
    return async (values: Input, _, options) => {
      try {
        const data = await schema[
          resolverOptions.mode === 'sync' ? 'parse' : 'parseAsync'
        ](values, schemaOptions);

        options.shouldUseNativeValidation &&
          validateFieldsNatively({}, options);

        return {
          errors: {},
          values: resolverOptions.raw ? Object.assign({}, values) : data,
        } satisfies ResolverSuccess<Output | Input>;
      } catch (error) {
        if (isZod3Error(error)) {
          return {
            values: {},
            errors: toNestErrors(
              parseZod3Issues(
                error.errors,
                !options.shouldUseNativeValidation &&
                  options.criteriaMode === 'all',
              ),
              options,
            ),
          } satisfies ResolverError<Input>;
        }

        throw error;
      }
    };
  }

  throw new Error('Invalid input: not a Zod schema');
}
```

[zod/src/zod.ts](https://github.com/react-hook-form/resolvers/blob/f14fc25bbf205e92266c8abf8512b3b517bcae4a/zod/src/zod.ts#L288-L388) · [More projects using Zod →](https://dashboard.exa.ai/playground/search?q=JavaScript%20projects%20that%20use%20zod&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```typescript
import * as z from "zod";

const Player = z.object({
  username: z.string(),
  xp: z.number(),
});

Player.parse({ username: "billie", xp: 100 });
// => returns { username: "billie", xp: 100 }

```

From [README.md](https://cdn.jsdelivr.net/npm/zod@4.6.7/README.md)

### Effect

[GitHub](https://github.com/Effect-TS/effect) · [npm](https://www.npmjs.com/package/effect) · [Docs](https://cdn.jsdelivr.net/npm/effect@4.1.4/dist/Schema.d.ts)

Effect is a TypeScript standard library, and its `Schema` module defines schemas that validate and transform data. A schema describes two types: the encoded form that arrives as input and the type the app works with. `Schema.decodeUnknownSync` turns unknown input into the app's type or throws, and encoding converts a value back for output. The same schema can also produce a JSON Schema, test data generators, and equality checks. Decoders that return an `Effect` connect to the rest of the Effect library, such as its error handling and concurrency.

- Downloads / mo: 271.4M
- Stars: 17.6K
- Last release: 4.1.4
- License: MIT
- Capabilities: [From the Effect docs](https://cdn.jsdelivr.net/npm/effect@4.1.4/dist/Schema.d.ts)

**Strengths**

- **Decodes and encodes.** One schema turns input into the app's type and converts it back for output.

**Watch out for**

- **Needs strict TypeScript.** The strict flag has to be on in tsconfig.json.

```sh
npm install effect@4.1.4
```

**react-hook-form/resolvers** (2.3K stars)

[react-hook-form/resolvers](https://github.com/react-hook-form/resolvers) 

```typescript
export function effectTsResolver<Input extends FieldValues, Context, Output>(
  schema: Schema.Codec<Output, Input, never, unknown>,
  schemaOptions: ParseOptions = { errors: 'all', onExcessProperty: 'ignore' },
  resolverOptions: { raw?: boolean } = {},
): Resolver<Input, Context, Output | Input> {
  return (values, _, options) =>
    Schema.decodeUnknownEffect(schema)(values, schemaOptions).pipe(
      Effect.match({
        onFailure: ({ issue }) => {
          const validateAllFieldCriteria =
            !options.shouldUseNativeValidation &&
            options.criteriaMode === 'all';

          // A null-prototype accumulator avoids false-positive hits from
          // inherited members (e.g. `toString`, `constructor`) when a field
          // is named after one of them — a plain `{}` would make `!acc[key]`
          // truthy-skip those paths and silently drop their errors.
          const errors = flattenIssue(issue, []).reduce(
            (acc, error) => {
              const key = error.path.join('.');

              if (!acc[key]) {
                acc[key] = { message: error.message, type: error.type };
              }

              if (validateAllFieldCriteria) {
                const types = acc[key].types;
                const messages = types && types[error.type];

                acc[key] = appendErrors(
                  key,
                  validateAllFieldCriteria,
                  acc,
                  error.type,
                  messages
                    ? ([] as string[]).concat(
                        messages as string[],
                        error.message,
                      )
                    : error.message,
                ) as FieldError;
              }

              return acc;
            },
            Object.create(null) as Record<string, FieldError>,
          );

          return { errors: toNestErrors(errors, options), values: {} };
        },
        onSuccess: (result) => {
          options.shouldUseNativeValidation &&
            validateFieldsNatively({}, options);

          return {
            errors: {},
            values: resolverOptions.raw ? Object.assign({}, values) : result,
          };
        },
      }),
      Effect.runPromise,
    );
}
```

[effect-ts/src/effect-ts.ts](https://github.com/react-hook-form/resolvers/blob/f14fc25bbf205e92266c8abf8512b3b517bcae4a/effect-ts/src/effect-ts.ts#L73-L135) · [More projects using Effect →](https://dashboard.exa.ai/playground/search?q=effect%20GitHub%20projects)

**Quickstart**

```typescript
import { Schema } from 'effect';

const User = Schema.Struct({
  name: Schema.String,
});

console.log(Schema.decodeUnknownSync(User)({ name: 'Ada' }));

```

From [Schema.d.ts](https://cdn.jsdelivr.net/npm/effect@4.1.4/dist/Schema.d.ts)

### validator.js

[GitHub](https://github.com/validatorjs/validator.js) · [npm](https://www.npmjs.com/package/validator) · [Docs](https://cdn.jsdelivr.net/npm/validator@13.15.35/README.md)

validator.js is a library of string validators and sanitizers, with functions such as `isEmail`, `isURL`, and `isMobilePhone`. Each validator takes a string and returns true or false, and sanitizers such as `escape` and `trim` return a cleaned string. The library checks strings only, so other input has to be converted to a string first. Single functions can be imported on their own, and a standalone script runs in the browser.

- Downloads / mo: 137.1M
- Stars: 23.7K
- Last release: 13.15.35
- License: MIT
- Capabilities: [From the validator.js docs](https://cdn.jsdelivr.net/npm/validator@13.15.35/README.md)

**Watch out for**

- **Strings only.** Passing a number or an object throws an error, so convert input to a string first.

```sh
npm install validator@13.15.35
```

**vinejs/vine** (1.3K stars)

[vinejs/vine](https://github.com/vinejs/vine) 

```typescript
function mobile(value, options, field) {
  const normalizedOptions = options && typeof options === 'function' ? options(field) : options
  const locales = normalizedOptions?.locale || 'any'

  if (!helpers.isMobilePhone(value as string, locales, normalizedOptions)) {
    field.report(messages.mobile, 'mobile', field)
  }
}
```

[src/schema/string/rules.ts](https://github.com/vinejs/vine/blob/17f9ea96672201c8f6cc472ca46b2b40b0126fe8/src/schema/string/rules.ts#L92-L99) · [More projects using validator.js →](https://dashboard.exa.ai/playground/search?q=validator%20GitHub%20projects)

**Quickstart**

```typescript
var validator = require('validator');

validator.isEmail('foo@bar.com'); //=> true


```

From [README.md](https://cdn.jsdelivr.net/npm/validator@13.15.35/README.md)

### Joi

[GitHub](https://github.com/hapijs/joi) · [npm](https://www.npmjs.com/package/joi) · [Docs](https://joi.dev/api/18.x.x/)

Joi describes objects with a chained schema language, such as `Joi.object` with `Joi.string` and `Joi.number` fields, in plain JavaScript. `schema.validate` returns an object with the validated value and any error, and `validateAsync` handles rules that need to wait on other work. Values convert to the declared types by default, so a numeric string passes as a number. Rules can also reference other fields, which covers checks such as a password confirmation.

- Downloads / mo: 132.0M
- Stars: 21.2K
- Last release: 18.3.2
- License: BSD-3-Clause
- Capabilities: [From the Joi docs](https://joi.dev/api/18.x.x/)

**Strengths**

- **Converts input values by default.** Strings and other inputs convert to the required types unless convert is false.
- **Supports synchronous and async validation.** validate runs synchronously, and validateAsync supports async rules.

**Watch out for**

- **Custom rules run synchronously.** Rules written with any.custom can't be asynchronous.

```sh
npm install joi@18.3.2
```

**react-hook-form/resolvers** (2.3K stars)

[react-hook-form/resolvers](https://github.com/react-hook-form/resolvers) 

```typescript
(
    schema,
    schemaOptions = {
      abortEarly: false,
    },
    resolverOptions = {},
  ) =>
  async (values, context, options) => {
    const _schemaOptions = Object.assign({}, schemaOptions, {
      context,
    });

    let result: Record<string, any> = {};
    if (resolverOptions.mode === 'sync') {
      result = schema.validate(values, _schemaOptions);
    } else {
      try {
        result.value = await schema.validateAsync(values, _schemaOptions);
      } catch (e) {
        result.error = e;
      }
    }

    if (result.error) {
      return {
        values: {},
        errors: toNestErrors(
          parseErrorSchema(
            result.error,
            !options.shouldUseNativeValidation &&
              options.criteriaMode === 'all',
          ),
          options,
        ),
      };
    }

    options.shouldUseNativeValidation && validateFieldsNatively({}, options);

    return {
      errors: {},
      values: result.value,
    };
  }
```

[joi/src/joi.ts](https://github.com/react-hook-form/resolvers/blob/f14fc25bbf205e92266c8abf8512b3b517bcae4a/joi/src/joi.ts#L59-L102) · [More projects using Joi →](https://dashboard.exa.ai/playground/search?q=JavaScript%20projects%20that%20use%20joi&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```typescript
const Joi = require('joi');

const schema = Joi.object({
    a: Joi.string(),
});

const { error, value } = schema.validate({ a: 'a string' });

```

From [API.md](https://joi.dev/api/18.x.x/)

### Valibot

[GitHub](https://github.com/open-circle/valibot) · [npm](https://www.npmjs.com/package/valibot) · [Docs](https://cdn.jsdelivr.net/npm/valibot@1.5.0/README.md)

Valibot validates data with schemas built from small, separate functions. A schema such as `v.object` lists the fields, `v.pipe` chains checks like `v.email` or `v.minLength` onto a type, and `v.parse` validates input or throws. Because each function is imported on its own, a bundler keeps only the checks a schema uses. Static types come from `v.InferOutput`, and the library has no dependencies and runs in any JavaScript environment.

- Downloads / mo: 126.5M
- Stars: 9.1K
- Last release: 1.5.0
- License: MIT
- Capabilities: [From the Valibot docs](https://cdn.jsdelivr.net/npm/valibot@1.5.0/README.md)

**Strengths**

- **Small bundles.** Each check is its own function, so a bundler keeps only the ones a schema uses.
- **No dependencies.** Runs in any JavaScript environment, from servers to browsers.

```sh
npm install valibot@1.5.0
```

**react-hook-form/resolvers** (2.3K stars)

[react-hook-form/resolvers](https://github.com/react-hook-form/resolvers) 

```typescript
export function valibotResolver<Input extends FieldValues, Context, Output>(
  schema: BaseSchema<Input, Output, any> | BaseSchemaAsync<Input, Output, any>,
  schemaOptions?: Partial<
    Omit<Config<InferIssue<typeof schema>>, 'abortPipeEarly' | 'skipPipe'>
  >,
  resolverOptions: {
    /**
     * @default async
     */
    mode?: 'sync' | 'async';
    /**
     * Return the raw input values rather than the parsed values.
     * @default false
     */
    raw?: boolean;
  } = {},
): Resolver<Input, Context, Output | Input> {
  return async (values: Input, _, options) => {
    // Check if we should validate all field criteria
    const validateAllFieldCriteria =
      !options.shouldUseNativeValidation && options.criteriaMode === 'all';

    // Parse values with Valibot schema
    const result = await safeParseAsync(
      schema,
      values,
      Object.assign({}, schemaOptions, {
        abortPipeEarly: !validateAllFieldCriteria,
      }),
    );

    // If there are issues, return them as errors
    if (result.issues) {
      // Create errors object. A null-prototype object avoids false-positive
      // hits from inherited members (e.g. `toString`, `constructor`) when a
      // field is named after one of them — a plain `{}` would make
      // `!errors[path]` truthy-skip those paths and silently drop their
      // errors.
      const errors: Record<string, FieldError> = Object.create(null);

      // Iterate over issues to add them to errors object
      for (; result.issues.length; ) {
        const issue = result.issues[0];
        // Object-level checks report no dot path; keep them on the empty key
        const path = getDotPath(issue) ?? '';

        // Add first error of path to errors object
        if (!errors[path]) {
          errors[path] = { message: issue.message, type: issue.type };
        }

        // If configured, add all errors of path to errors object
        if (validateAllFieldCriteria) {
          const types = errors[path].types;
          const messages = types && types[issue.type];
          errors[path] = appendErrors(
            path,
            validateAllFieldCriteria,
            errors,
            issue.type,
            messages
              ? ([] as string[]).concat(
                  messages as string | string[],
                  issue.message,
                )
              : issue.message,
          ) as FieldError;
        }

        result.issues.shift();
      }

      // Return resolver result with errors
      return {
        values: {},
        errors: toNestErrors(errors, options),
      } as const;
    }

    options.shouldUseNativeValidation && validateFieldsNatively({}, options);

    // Otherwise, return resolver result with values
    return {
      values: resolverOptions.raw ? Object.assign({}, values) : result.output,
      errors: {},
    };
  };
}
```

[valibot/src/valibot.ts](https://github.com/react-hook-form/resolvers/blob/f14fc25bbf205e92266c8abf8512b3b517bcae4a/valibot/src/valibot.ts#L53-L140) · [More projects using Valibot →](https://dashboard.exa.ai/playground/search?q=valibot%20GitHub%20projects)

**Quickstart**

```typescript
import * as v from 'valibot';

const LoginSchema = v.object({
  email: v.pipe(v.string(), v.email()),
  password: v.pipe(v.string(), v.minLength(8)),
});

const output2 = v.parse(LoginSchema, {
  email: 'jane@example.com',
  password: '12345678',
});

```

From [README.md](https://cdn.jsdelivr.net/npm/valibot@1.5.0/README.md)

### class-validator

[GitHub](https://github.com/typestack/class-validator) · [npm](https://www.npmjs.com/package/class-validator) · [Docs](https://cdn.jsdelivr.net/npm/class-validator@0.15.1/README.md)

class-validator checks objects through decorators placed on class properties, such as `@IsEmail`, `@Length`, and `@Min`. `validate` runs every rule on an instance and returns a list of errors, and `validateOrReject` throws instead. The checks themselves come from validator.js. Validation groups, nested objects, and custom decorators are supported, and rules can also be defined without decorators. Plain objects, such as parsed JSON, have to be turned into class instances first.

- Downloads / mo: 67.3M
- Stars: 11.9K
- Last release: 0.15.1
- License: MIT
- Capabilities: [From the class-validator docs](https://cdn.jsdelivr.net/npm/class-validator@0.15.1/README.md)

**Strengths**

- **Rules as decorators.** Decorators such as IsEmail run validator.js checks on class properties.

**Watch out for**

- **Class instances only.** Plain objects have to become class instances first, for example with class-transformer.

```sh
npm install class-validator@0.15.1
```

**medusajs/medusa** (37.3K stars)

[medusajs/medusa](https://github.com/medusajs/medusa) 

```typescript
export async function validator<T, V>(
  typedClass: ClassConstructor<T>,
  plain: V,
  config: ValidatorOptions = {}
): Promise<T> {
  typedClass = extendedValidators.get(typedClass.name) ?? typedClass

  const toValidate = plainToInstance(typedClass, plain)
  // @ts-ignore
  const errors = await validate(toValidate, {
    whitelist: true,
    forbidNonWhitelisted: true,
    ...config,
  })

  const errorMessages = reduceErrorMessages(errors)

  if (errors?.length) {
    throw new MedusaError(
      MedusaError.Types.INVALID_DATA,
      errorMessages.join(", ")
    )
  }

  return toValidate
}
```

[packages/medusa/src/utils/validator.ts](https://github.com/medusajs/medusa/blob/2c444a06e8fe16b749f1c7303ba93d3df36166c8/packages/medusa/src/utils/validator.ts#L48-L73) · [More projects using class-validator →](https://dashboard.exa.ai/playground/search?q=class-validator%20GitHub%20projects)

**Quickstart**

```typescript
import { IsEmail, validate } from 'class-validator';

class EmailInput {
  @IsEmail()
  email = 'jane@example.com';
}

console.log(await validate(new EmailInput()));

```

From [README.md](https://cdn.jsdelivr.net/npm/class-validator@0.15.1/README.md)

### TypeBox

[GitHub](https://github.com/sinclairzx81/typebox) · [npm](https://www.npmjs.com/package/typebox) · [Docs](https://cdn.jsdelivr.net/npm/typebox@1.4.7/readme.md)

TypeBox builds JSON Schema objects in TypeScript with functions such as `Type.Object` and `Type.Number`, and `Type.Static` reads the matching TypeScript type from each one. The result is one definition that TypeScript checks at compile time and any JSON Schema validator checks at runtime. TypeBox also includes its own compiler and value functions, so validation can run without a separate library. Services that already exchange JSON Schema, such as REST and RPC APIs, can use the schemas as they are.

- Downloads / mo: 65.2M
- Stars: 7.0K
- Last release: 1.4.7
- License: MIT
- Capabilities: [From the TypeBox docs](https://cdn.jsdelivr.net/npm/typebox@1.4.7/readme.md)

**Strengths**

- **One definition, two uses.** The same object is a TypeScript type at compile time and a JSON Schema at runtime.

```sh
npm install typebox@1.4.7
```

**fastify/fastify-type-provider-typebox** (205 stars)

[fastify/fastify-type-provider-typebox](https://github.com/fastify/fastify-type-provider-typebox) 

```typescript
({ schema, httpPart }) => {
  const typeCheck = Compile(schema)
  return (value): any /* TODO: remove any for next major */ => {
    // Note: Only support value conversion for querystring, params and header schematics
    const converted = httpPart === 'body' ? value : Value.Convert(schema, value)
    if (typeCheck.Check(converted)) {
      return { value: converted }
    }

    const errors: FastifySchemaValidationError[] = typeCheck.Errors(converted)

    return {
      error: errors
    }
  }
}
```

[index.ts](https://github.com/fastify/fastify-type-provider-typebox/blob/d81731b31f4ec47e0dafa0cc28ccf1f58ebbec52/index.ts#L94-L109) · [More projects using TypeBox →](https://dashboard.exa.ai/playground/search?q=typebox%20GitHub%20projects)

**Quickstart**

```typescript
import Type from 'typebox'

import Schema from 'typebox/schema'

// Compile

const Vector = Schema.Compile(Type.Script(`{
  x: number
  y: number
  z: number
}`))

// Check

const valid = Vector.Check({ x: 1, y: 0, z: 0 })   // const valid: boolean

```

From [readme.md](https://cdn.jsdelivr.net/npm/typebox@1.4.7/readme.md)

## FAQ

### Which JavaScript validation library should I use?

In TypeScript, [Zod](#zod) defines a schema once and infers its type, and [Valibot](#valibot) does the same with separately imported functions that keep bundles small. For data described in JSON Schema, use [Ajv](#ajv). For rules written as decorators on classes, use [class-validator](#class-validator), and for single strings such as email addresses, [validator.js](#validator).

### Zod vs Yup: which should I use?

Yup casts input into the declared types and can transform it before validating. Zod parses input and returns a typed deep copy when it is valid, and it infers the TypeScript type from the schema.

### Joi vs Zod: which should I use?

Joi validates objects in plain JavaScript and converts values, such as a numeric string to a number, by default. Zod is TypeScript first: one schema gives both the runtime check and the static type.

### Valibot vs Zod: which should I use?

Both define schemas in TypeScript and infer static types. Valibot splits its API into separate functions, such as `v.pipe` and `v.email`, so a bundler keeps only the ones in use, and its bundle starts under one kilobyte. Zod chains methods on a schema object.

### Ajv vs Zod: which should I use?

Ajv validates data against JSON Schema documents and compiles each schema into a reusable function. Zod defines schemas in TypeScript and infers types from them. When another tool needs JSON Schema, `z.toJSONSchema` exports a Zod schema to that format.

## How this page was built

Data checked Nov 19, 2026.

Reproduce it with the Exa API:

```json
{
  "endpoint": "/search",
  "body": {
    "query": "JavaScript validation libraries Zod Yup Joi Ajv coercion async custom schema validation code examples",
    "numResults": 5
  }
}
```

Docs: https://exa.ai/docs/reference/search
