validator.js

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

Library
npm
v13.15.35
23,740 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
70 /100 Good
Development Activity 56
Maintenance 48
Community 76
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
87 /100 Excellent
Architecture 90
Code Quality 88
Innovation 90
Learning Curve 90

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

JavaScript
55%
Other

Lokus

Knowledge Management · Note Taking

829

Local-first note-taking with graph view, canvas & AI plugins—your Markdown files, zero telemetry, blazing-fast Rust performance.

View details
75
Repo Health
75
Technical
64
Dependency
Built with
JavaScript 55%
HTML 21%
Rust 12%
Updated 1 months ago
TypeScript
88%
Apache 2.0

Medplum

Authentication · Databases · Developer Tools

2,760

An open-source, FHIR-native healthcare platform that gives developers a compliant backend, authentication, a React component library, and serverless bots to build clinical applications in weeks instead of years.

View details
93
Repo Health
90
Technical
71
Dependency
Built with
TypeScript 88%
Updated yesterday
TypeScript
87%
MIT

medusa

Ecommerce

36,897

The most flexible open-source commerce platform — build B2C, B2B, and marketplace applications with modular, composable commerce primitives.

View details
94
Repo Health
87
Technical
63
Dependency
Built with
TypeScript 87%
JavaScript 12%
Updated 2 days ago
TypeScript
92%
Other

n8n

Automation · No Code Platforms

208,437

Code when you need it, UI when you don't — the workflow automation platform built for technical teams who refuse to choose.

View details
95
Repo Health
87
Technical
62
Dependency
Built with
TypeScript 92%
Updated 2 days ago
TypeScript
65%
Other

NocoDB

Databases · Low Code Platforms · No Code Platforms

65,340

Turn any SQL database into a collaborative no-code spreadsheet with automatic REST APIs and real-time views.

View details
91
Repo Health
77
Technical
63
Dependency
Built with
TypeScript 65%
Vue 30%
Updated yesterday
JavaScript
88%
GPL 3.0

NodeBB

Community

15,242

Modern Node.js forum software with real-time WebSockets, multi-database support, and a plugin ecosystem — the community platform built for the open web and the Fediverse.

View details
97
Repo Health
78
Technical
70
Dependency
Built with
JavaScript 88%
Go Template 11%
Updated yesterday
TypeScript
85%
GPL 3.0

Notesnook

File Storage · Note Taking · Security

14,822

End-to-end encrypted, open-source note-taking where your data stays yours — even from the server.

View details
91
Repo Health
84
Technical
60
Dependency
Built with
TypeScript 85%
JavaScript 12%
Updated yesterday
TypeScript
82%
AGPL 3.0

OpenStatus

Devops · Monitoring

9,221

Open-source status pages and uptime monitoring with global synthetic checks, monitoring-as-code, and AI agent integration via MCP.

View details
77
Repo Health
82
Technical
69
Dependency
Built with
TypeScript 82%
MDX 14%
Updated 2 days ago
TypeScript
98%
Other

Outline

Collaboration · Knowledge Management

41,045

A fast, real-time collaborative knowledge base for growing teams built on React, Node.js, and ProseMirror.

View details
91
Repo Health
87
Technical
68
Dependency
Built with
TypeScript 98%
Updated yesterday

Join founders buildingwith open source

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

Subscribe on Substack
Join 750+ subscribers