Back to all patterns
NanoID
Validation
Validates a default 21-character NanoID.
/^[A-Za-z0-9_-]{21}$/How it works
NanoID by default produces 21-character URL-safe IDs. The default alphabet is A-Z a-z 0-9 _ -. Custom alphabets and lengths exist; this regex matches the default.
Test Cases
Should Match
- V1StGXR8_Z5jdHi6B-myT
- abcDEF123-_xyzABC1234
Should NOT Match
- V1StGXR8_Z5jdHi6B-my
- V1StGXR8_Z5jdHi6B-myTT
Quick Summary
Matches default 21-character URL-safe NanoIDs (A-Z, a-z, 0-9, _, -).