Try it Live
Run Address examples in the interactive playground
Validation Rules
With0x prefix:
- Exactly 42 characters total
- First 2 characters:
0x - Next 40 characters: valid hex (0-9, a-f, A-F)
0x prefix:
- Exactly 40 characters total
- All characters: valid hex (0-9, a-f, A-F)
- Accepts lowercase, uppercase, or mixed case
- Does not validate EIP-55 checksum
Use Cases
Input Validation
Validate user input before parsing:Form Validation
Validate addresses in forms:API Input Validation
Validate addresses in API requests:Defensive Programming
Check before processing:Common Invalid Inputs
Validation Without Checksum
isValid() does NOT validate EIP-55 checksums:
Performance
Fast validation: Checks length and character ranges only. No parsing: Does not allocate or parse hex values. Use before parsing: Validate first to avoid exceptions:Type Narrowing
Use as type guard in TypeScript:See Also
- isValidChecksum - Validate EIP-55 checksum
- fromHex - Parse address from hex
- from - Universal constructor
- EIP-55: Mixed-case checksum

