validator.js
A dependency-free library of 100+ string validators and sanitizers for Node.js and the browser.
Repository Health
Technical Analysis
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
PeerTube
Social Media
A federated, ActivityPub-based video hosting platform built by Framasoft — self-hostable instances interconnect into a network with no vendor lock-in, P2P-assisted streaming, and no ads.
Plasmic
CMS · Design Tools · Low Code Platforms
The open-source visual builder that lets teams design React apps and websites with drag-and-drop while integrating seamlessly with your codebase.
Puter
Developer Tools · File Storage
A self-hostable, web-based internet OS with desktop GUI, cloud storage, AI drivers, and a developer SDK — all running in your browser.
Responsively App
Design Tools · Developer Tools
Preview and interact with your responsive web design across every device size simultaneously — no more manual resizing.
superglue
AI Agents · Data Engineering · Developer Tools
superglue is an AI-agent-driven integration engine that turns plain-English descriptions of enterprise systems into production-grade API tools, ERP/CRM connectors, and data pipelines — self-hosted or cloud, Y Combinator-backed (W25).
Typebot
AI Assistants · AI Development · Developer Tools
Build sophisticated chatbots visually, embed them anywhere without iframes, and own your data — fully self-hostable with a modular block system and 30+ integrations.
Uptime Kuma
Monitoring
Self-hosted monitoring for every service you run — 23 monitor types, 95 notification channels, live dashboards, and public status pages with no vendor lock-in.
Webiny JS
Blogging · CMS · Ecommerce
Open-source, self-hosted CMS on AWS serverless — a TypeScript framework you extend with code, not a product you configure through a UI.