regex.to/validators
A polyglot regular expression registry. One single source of truth for 85+ patterns (email, URLs, dates, country-specific identifiers, markdown formats), distributed as zero-dependency native packages for your backend or frontend of choice.
Overview
Maintaining custom regex patterns across multiple languages is prone to bugs. `regex.to` solves this by packaging the exact same validated JSON pattern registry into native, optimized libraries for:
- JavaScript / TypeScript: First-class Zod support and full validation schema.
- Python: Native, type-hinted package.
- Go: Advanced PCRE-compatible support using `regexp2` (avoids RE2 lookaround limitations).
- PHP: Full native PCRE pattern validation.
- Rust: Fast compiled validation using `fancy-regex` (supports lookarounds).
Each library exposes the exact same unified interface: `validate` (strict full string match), `test` (partial substring match), and `detect` (automatically identify pattern types).
JavaScript / TypeScript (NPM)
Install the `@regexto/validators` package:
npm install @regexto/validatorsUsage
import { validate, test, getRegex } from '@regexto/validators';
// Full validation match
const res = validate('email', 'hello@regex.to'); // { valid: true, ... }
// Fast boolean check
const isUrl = test('url', 'https://regex.to'); // true
// Fetch compiled RegExp object
const rx = getRegex('email'); // /[a-zA-Z0-9...]/Zod Integration
Import Zod-specific helpers directly:
import { zodSchema, zodObjectSchema } from '@regexto/validators/zod';
import { z } from 'zod';
const schema = zodObjectSchema({
email: 'email',
website: 'url',
});Python (PyPI)
Install the `regexto-validators` package:
pip install regexto-validatorsUsage
from regexto_validators import validate, test
# Full validation match
is_valid = validate("email", "hello@regex.to") # True
# Fast boolean check
is_url = test("url", "https://regex.to") # TrueGo (pkg.go.dev)
Download the module. Uses PCRE-compatible `regexp2` under the hood:
go get github.com/regex-to/validators-goUsage
package main
import (
"fmt"
"github.com/regex-to/validators-go"
)
func main() {
valid, _ := validators.Validate("email", "hello@regex.to")
fmt.Println(valid) // true
}PHP (Packagist)
Require via Composer:
composer require regexto/validatorsUsage
<?php
use RegexTo\Validators\Validator;
$isValid = Validator::validate('email', 'hello@regex.to'); // trueRust (Crates.io)
Add to your dependencies. Uses `fancy-regex` to cleanly support patterns with lookarounds:
cargo add regexto-validatorsUsage
use regexto_validators::validate;
fn main() {
let is_valid = validate("email", "hello@regex.to").unwrap();
println!("Valid? {}", is_valid); // true
}detect() — Auto-detect string type
Pass any unknown string and get back an ordered list of matching patterns. `detect` is available in all supported languages, utilizing the exact same ranking heuristics.
// Example showing auto-detection structure
import { detect } from '@regexto/validators';
detect('hello@regex.to');
// → [{ pattern: { slug: 'email', ... }, matchType: 'full', coverage: 1 }]Results are sorted by confidence: full matches first, then by coverage ratio. Minimum match length is 4 characters and 20% coverage to filter trivial hits.
API Reference
| Function | Description |
|---|---|
test(slug, value) | Quick boolean substring match |
validate(slug, value) | Full strict match validation |
detect(input) | Auto-detect type of an unknown string |
getAllPatterns() | All patterns as an array |
Patterns (85)
fr-postalFrench Postal Code
Matches a French postal code — exactly 5 digits, starting with 0–9.
de-plzGerman Postal Code (PLZ)
Matches a German postal code (Postleitzahl / PLZ) — exactly 5 digits.
uk-postcodeUK Postcode
Matches a UK postcode in the standard format (e.g. SW1A 1AA, EC1A 1BB).
us-zipUS ZIP Code
Matches a US ZIP code in 5-digit or ZIP+4 (5-4) format.
crypto-mnemonic-wordBIP-39 Mnemonic Phrase
Matches a BIP-39 mnemonic seed phrase — 12, 15, 18, 21, or 24 lowercase English words separated by single spaces.
bitcoin-addressBitcoin Address (Legacy)
Matches a legacy Bitcoin address — P2PKH (starting with 1) or P2SH (starting with 3), 25–34 Base58 characters.
bech32-addressBitcoin Bech32 Address (SegWit)
Matches a Bitcoin native SegWit address in Bech32 format — starts with bc1 followed by 6–87 lowercase alphanumeric characters.
ens-nameENS Name (Ethereum Name Service)
Matches an Ethereum Name Service domain — alphanumeric label(s) ending with .eth.
ethereum-addressEthereum Address
Matches an Ethereum address — 0x followed by exactly 40 hexadecimal characters.
txhash-ethEthereum Transaction Hash
Matches an Ethereum transaction hash — 0x followed by exactly 64 hexadecimal characters.
ipfs-cidIPFS CID
Matches an IPFS Content Identifier (CIDv0 starting with Qm, or CIDv1 starting with bafy/bafk).
lightning-invoiceLightning Network Invoice (BOLT-11)
Matches a Bitcoin Lightning Network payment invoice in BOLT-11 format — starts with lnbc, lntb, or lnbcrt.
monero-addressMonero Address
Matches a Monero (XMR) standard address — starts with 4 and is exactly 95 Base58 characters.
solana-addressSolana Address
Matches a Solana public key — 32–44 Base58 characters (no 0, O, I, l).
date-euDate (European Format)
Matches a European-style date in DD/MM/YYYY, DD.MM.YYYY, or DD-MM-YYYY format.
date-usDate (US Format)
Matches a US-style date in MM/DD/YYYY format.
iso-dateISO 8601 Date
ISO 8601 date format (YYYY-MM-DD) with month and day range validation.
datetime-isoISO 8601 DateTime
Matches an ISO 8601 datetime string with timezone offset or Z (UTC).
time-24hTime (24-hour)
Matches a time in 24-hour format. Supports both HH:MM and HH:MM:SS.
conventional-commitConventional Commit Message
Validates git commit messages adhering to the Conventional Commits specification.
cron-expressionCron Expression
Validates cron schedule expressions (5 fields: minute, hour, day of month, month, day of week) structurally.
openai-api-keyOpenAI API Key
Validates OpenAI API keys, specifically supporting the standard project keys starting with 'sk-proj-'.
credit-cardCredit Card Number
Generic credit card number validator supporting Visa, Mastercard, American Express, and Discover card formats.
ibanIBAN
Matches an International Bank Account Number (IBAN) — 2-letter country code, 2 check digits, and up to 30 alphanumeric characters.
pl-nipPolish NIP (Tax ID)
Polish NIP (Numer Identyfikacji Podatkowej) — the 10-digit tax identification number used by businesses and self-employed individuals in Poland.
swift-bicSWIFT / BIC Code
Matches a SWIFT/BIC (Bank Identifier Code) — 6-letter institution code + 2-letter country + optional 2-3 character branch.
coordinatesGPS Coordinates
Matches a latitude,longitude coordinate pair separated by a comma.
latitudeLatitude
Matches a geographic latitude coordinate between -90 and +90 degrees, with up to 6 decimal places.
longitudeLongitude
Matches a geographic longitude coordinate between -180 and +180 degrees, with up to 6 decimal places.
au-abnAustralian ABN
Matches an Australian Business Number (ABN) — 11 digits, optionally space-separated in groups.
br-cnpjBrazilian CNPJ
Matches a Brazilian CNPJ (Cadastro Nacional da Pessoa Jurídica) — company identifier in formatted or unformatted form.
br-cpfBrazilian CPF
Matches a Brazilian CPF (Cadastro de Pessoas Físicas) number in formatted (NNN.NNN.NNN-NN) or unformatted (NNNNNNNNNNN) form.
cn-resident-idChinese Resident ID
Matches a Chinese national resident identity card number — 17 digits followed by one digit or X (checksum digit).
fr-sirenFrench SIREN Number
Matches a French SIREN (Système d'Identification du Répertoire des ENtreprises) number — 9 digits.
fr-siretFrench SIRET Number
Matches a French SIRET (Système d'Identification du Répertoire des Établissements) number — 14 digits.
de-steueridGerman Tax ID (Steuer-IdNr)
Matches a German personal tax identification number (Steuerliche Identifikationsnummer) — 11 digits, first digit 1–9.
in-panIndian PAN Card
Matches an Indian Permanent Account Number (PAN) — 10 characters: 5 uppercase letters, 4 digits, 1 uppercase letter.
it-codice-fiscaleItalian Codice Fiscale
Matches an Italian fiscal code (Codice Fiscale) — 16 alphanumeric characters encoding name, birth date, gender, and municipality.
pl-peselPolish PESEL
Polish national identification number (PESEL) — an 11-digit number encoding date of birth, gender, and a checksum, assigned to every citizen.
pl-regonPolish REGON
Matches a Polish REGON (National Business Registry Number) — 9 digits for companies, 14 digits for local units.
ru-innRussian INN (ИНН)
Matches a Russian taxpayer identification number (ИНН) — 10 digits for organisations, 12 digits for individuals.
es-nifSpanish NIF / DNI
Matches a Spanish National Identity Document number (NIF/DNI) — 8 digits followed by a letter, or an NIE starting with X, Y, or Z.
uk-ninoUK National Insurance Number (NINO)
Matches a UK National Insurance Number in the format AA 99 99 99 A.
us-einUS Employer Identification Number (EIN)
Matches a US EIN (Federal Tax ID) in the NN-NNNNNNN format used by the IRS.
us-ssnUS Social Security Number
Matches a US Social Security Number (SSN) in the standard NNN-NN-NNNN format.
domainDomain Name
Matches a valid domain name including subdomains and international TLDs.
emailEmail Address
RFC 5321 compliant email address validation. Supports subdomains, plus-addressing, and international TLDs.
urlURL (HTTP/HTTPS)
Validates HTTP and HTTPS URLs including subdomains, paths, query strings, and anchors.
youtube-urlYouTube Video URL
Matches a YouTube video URL in both youtube.com/watch?v= and youtu.be/ formats and extracts the 11-character video ID.
markdown-blockquoteMarkdown Blockquote
Matches a Markdown blockquote line beginning with > and captures the quoted text.
markdown-boldMarkdown Bold
Matches Markdown bold text wrapped in **double asterisks** or __double underscores__.
markdown-headingMarkdown Heading
Matches Markdown ATX-style headings — # through ###### followed by text. Captures both the level (number of #) and the heading text.
markdown-hrMarkdown Horizontal Rule
Matches a Markdown horizontal rule — three or more dashes, asterisks, or underscores on a line.
markdown-imageMarkdown Image
Matches a Markdown image tag  and captures both the alt text and the URL.
markdown-code-inlineMarkdown Inline Code
Matches Markdown inline code wrapped in single `backticks` or ``double backticks``.
markdown-italicMarkdown Italic
Matches Markdown italic text wrapped in *single asterisk* or _single underscore_.
markdown-list-itemMarkdown List Item
Matches Markdown unordered list items starting with -, *, or + and ordered items starting with a number.
markdown-table-rowMarkdown Table Row
Matches a Markdown GFM table row — cells separated by pipe | characters.
ipv4IPv4 Address
Validates a standard IPv4 address ensuring each octet is 0–255.
ipv6IPv6 Address
Matches a full-form IPv6 address with 8 groups of 4 hexadecimal digits separated by colons.
mac-addressMAC Address
Matches a MAC (Media Access Control) address in both colon-separated and hyphen-separated formats.
port-numberPort Number
Matches a valid TCP/UDP port number from 0 to 65535.
phone-e164Phone — E.164 International
Matches an international phone number in E.164 format: + followed by country code and subscriber number (max 15 digits total).
phone-ukPhone — UK
Matches UK phone numbers in standard formats, starting with 0 or +44.
phone-usPhone — US
Matches a US phone number in various formats: (555) 867-5309, 555-867-5309, 5558675309, or with +1 country code.
base64Base64 Encoded String
Matches a valid Base64-encoded string with proper padding using = characters.
jwtJWT Token
Matches a JSON Web Token (JWT) — three Base64URL-encoded segments separated by dots.
md5MD5 Hash
Matches an MD5 hash — exactly 32 hexadecimal characters.
sha256SHA-256 Hash
Matches a SHA-256 cryptographic hash — exactly 64 hexadecimal characters.
ssh-public-keySSH Public Key
Validates SSH public keys, supporting common algorithms like ssh-rsa, ssh-ed25519, ssh-dss, and ecdsa variants.
password-strongStrong Password
Matches a strong password: minimum 8 characters with at least one uppercase letter, one lowercase letter, one digit, and one special character.
uuidUUID v4
Matches a UUID version 4 — randomly generated universally unique identifier in the standard 8-4-4-4-12 format.
mention@Mention
Matches a social media @mention — @ followed by 3–30 word characters.
hashtagHashtag
Matches a social media hashtag — # followed by one or more word characters (letters, digits, underscores), starting with a letter.
usernameUsername
Matches a valid username: 3–20 characters, letters, digits, hyphens, and underscores. No leading/trailing hyphens or underscores.
hex-colorHex Color
CSS hex color code in #RGB or #RRGGBB format (case-insensitive).
html-tagHTML Tag
Matches an HTML opening or self-closing tag with optional attributes.
markdown-linkMarkdown Link
Matches a Markdown hyperlink in [text](url) format and captures both the link text and URL.
slugURL Slug
Valid URL slug — lowercase alphanumeric characters separated by single hyphens, no leading or trailing hyphens.
Contributing a Pattern
All patterns are stored as small JSON files. Contributing is a 4-step process:
- 1
Fork the repository
Fork github.com/regex-to/validators and create a branch:
pattern/your-pattern-name - 2
Create the JSON file
json{ "slug": "your-pattern", "name": "Human Readable Name", "description": "What this regex validates.", "category": "Internet", "pattern": "your[regex]pattern+", "flags": "i", "examples": ["valid-input-1", "valid-input-2"], "counterExamples": ["invalid-1"], "tags": ["tag1", "tag2"] } - 3
Test your pattern
bashnpm test # Or paste your pattern into the sandbox at regex.to - 4
Open a Pull Request
Open a PR titled
feat: add [pattern-name] pattern. Patterns are auto-discovered on merge.
