Skip to content
Package59 repository health

validator.js

A dependency-free library of 100+ string validators and sanitizers for Node.js and the browser.

Library npmv13.15.3523,743 stars MIT License
npm install validator
View source

Repository health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
Fair
  • Development activity32
  • Maintenance28
  • Community76
  • Maturity60
  • Momentum40

Technical analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
Excellent
  • Architecture90
  • Code quality88
  • Innovation90
  • Learning curve90

Validator.js is a widely-used JavaScript library that provides a comprehensive collection of string validation and sanitization functions. It ships more than a hundred small, focused checkers for common formats such as emails, URLs, dates, credit cards, IP addresses, UUIDs, and dozens of locale-aware alphabetic and numeric patterns, alongside sanitizers that normalize, escape, or trim input.

Built as a flat set of pure functions with zero runtime dependencies, it works identically on the server and in the browser and supports tree-shakeable ES imports so you can pull in only the validators you need. Its explicit string-only contract keeps behavior predictable and makes it a dependable building block for form handling, request validation, and data cleaning.

What You Get

  • 100+ ready-made validators covering emails, URLs, dates, credit cards, IPs, UUIDs, hashes, and more
  • A suite of sanitizers for trimming, escaping, blacklisting, and normalizing strings
  • Locale-aware checks (isAlpha, isAlphanumeric, isMobilePhone, isPostalCode) spanning dozens of regions
  • Zero runtime dependencies and tree-shakeable ES module imports for minimal bundle impact
  • Identical behavior across Node.js and the browser, plus a standalone/AMD build

Common Use Cases

  • Validating user-submitted form fields such as emails, phone numbers, and URLs
  • Sanitizing and normalizing untrusted input before persistence or display
  • Enforcing format constraints in API request validation layers
  • Checking identifiers like UUIDs, credit card numbers, or postal codes in data pipelines

Under The Hood

Architecture The library is organized as a flat collection of single-responsibility modules under src/lib, one file per validator or sanitizer (isEmail.js, isURL.js, trim.js), with shared helpers in src/lib/util (assertString, merge, checkHost). src/index.js imports every function and re-exports them as a single default object, while the package also publishes CommonJS (lib), tree-shakeable ES (es), and standalone browser (validator.min.js) builds so consumers can import the whole surface or a single function. Tech Stack It is written in modern JavaScript with zero runtime dependencies, transpiled through Babel (@babel/preset-env) and bundled with Rollup for the browser build and UglifyJS for minification. Tooling includes ESLint (airbnb-base config), Mocha with nyc for coverage, and timezone-mock for deterministic date tests. Code Quality Code quality is strong: the test directory contains dedicated suites for validators, sanitizers, client-side usage, and exports, exercising the large validator surface with extensive fixtures. Functions are small and pure, input is guarded via a shared assertString helper that throws on non-string input, and options are merged against explicit defaults, keeping behavior predictable. API Design The public API is deliberately minimal and consistent: predicate validators are named isX and return booleans, converters are named toX, and sanitizers read as verbs (trim, escape, blacklist). Every function takes the string as its first argument with an optional options object, so getting started requires almost no boilerplate, and the README documents each validator with its options inline.

Used by 26 apps in this directory

Every app whose dependencies include validator, nine to a page.

Showing 26 apps
TypeScript 96%Other

Amplication

16,010

AI Code Assistants · Automation · Developer Tools

Create production-ready backend services with your organization's standards baked in — generating NestJS, Prisma, and GraphQL code that you own and control.

App
Built with
  • TypeScript 96%
Updated 4 months agoView details
TypeScript 90%Other

CapRover

15,200

Developer Tools · Devops · Hosting Control Panel

Deploy any app, database, or website to your own server in minutes—no Docker or Linux expertise required.

App
Built with
  • TypeScript 90%
Updated 2 weeks agoView details
Java 34%Apache 2.0

Enso

7,442

Analytics · Data Engineering · Low Code Platforms

A visual and textual programming platform for data prep and analysis where the node graph and the underlying Enso code are always perfectly in sync, built by an Alteryx co-founder on a GraalVM engine.

App
Built with
  • Java 34%
  • TypeScript 27%
  • Scala 26%
Updated 3 months agoView details
TypeScript 64%MIT

Ghost

55,701

Blogging · CMS

Open source headless Node.js CMS for professional publishing, paid memberships, and newsletters with a fully owned audience.

App
Built with
  • TypeScript 64%
  • JavaScript 33%
Updated 1 weeks agoView details
JavaScript 88%GPL 3.0

Glass by Pickle

7,604

AI Assistants

A privacy-first desktop AI assistant that sees your screen, hears your meetings, and turns live context into structured summaries—without sending a single byte to the cloud.

App
Built with
  • JavaScript 88%
  • TypeScript 12%
Updated 1 years agoView details
TypeScript 96%AGPL 3.0

HeyForm

9,066

Forms Surveys · No Code Platforms

Open-source conversational form builder with AI generation, conditional logic, and 30+ integrations — self-host with full data ownership.

App
Built with
  • TypeScript 96%
Updated 2 weeks agoView details
TypeScript 71%Other

highlight.io

9,386

Analytics · Developer Tools · Monitoring

Open-source full-stack monitoring that unifies session replay, error tracking, logging, and distributed tracing so you can stop context-switching between tools.

App
Built with
  • TypeScript 71%
  • Go 16%
Updated 4 weeks agoView details
TypeScript 94%AGPL 3.0

Laudspeaker

2,631

Automation · Marketing

Open-source customer engagement platform for building visual, event-triggered messaging journeys across email, SMS, push, in-app, and webhooks.

App
Built with
  • TypeScript 94%
Updated 4 months agoView details
TypeScript 71%Other

LogChimp

1,135

Marketing · Product Management

Collect customer feedback, prioritize features with upvotes, and build transparent product roadmaps — fully self-hosted and open source.

App
Built with
  • TypeScript 71%
  • Vue 27%
Updated 2 weeks agoView details

Join founders building with open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on SubstackJoin 750+ subscribers