Validate legacy, segwit, native segwit (bech32) and taproot Bitcoin addresses

v2.1.0 2021-12-23 04:41 UTC

This package is auto-updated.

Last update: 2022-07-23 05:57:36 UTC


Author Build Packagist Version Software License Total Downloads

Validate legacy, segwit, native segwit (bech32), and taproot Bitcoin addresses.


  • PHP >= 7.3
PHP Package Version
7.x v1.0
8.x v2.0+

Please note that taproot addresses are supported from v2.1 of this package.


Install the package via composer:

composer require kielabokkie/bitcoin-address-validator


First you instantiate the validator class:

$addressValidator = new \Kielabokkie\Bitcoin\AddressValidator;

Validate any kind of address (legacy, segwit, native segwit and taproot):


Legacy (P2PKH) address:


Segwit (P2SH) address:


Native segwit (bech32) address:


Taproot (P2TR) address:



By default, the validator only passes mainnet addresses as valid. If you would like to validate both mainnet and testnet addresses you can use method chaining:

// Both valid

If you want to validate only testnet addresses you can do that as follows:

// Invalid
// Valid


This package is tested against the test data of the official bitcoin/bitcoin repo. If you come across an address that is not validated correctly please open an issue for it.

Run the tests with:

composer test


This package is based on the following packages and uses a lot of their code:

All credit goes to the original authors.


Did this package made you lots of money, save you some time or just sparked joy?

A donation would be much appreciated: 32vtWJSomccxQ6y1tgSwSHXN5PChpdYy27