PHPackages                             kielabokkie/bitcoin-address-validator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. kielabokkie/bitcoin-address-validator

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

kielabokkie/bitcoin-address-validator
=====================================

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

v2.2.0(2y ago)36283.0k↓18.5%7[2 issues](https://github.com/kielabokkie/bitcoin-address-validator/issues)[2 PRs](https://github.com/kielabokkie/bitcoin-address-validator/pulls)MITPHPPHP ^7.3|^7.4|^8.0|^8.1CI passing

Since Mar 18Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/kielabokkie/bitcoin-address-validator)[ Packagist](https://packagist.org/packages/kielabokkie/bitcoin-address-validator)[ GitHub Sponsors](https://github.com/kielabokkie)[ RSS](/packages/kielabokkie-bitcoin-address-validator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)DependenciesVersions (7)Used By (0)

Bitcoin Address Validator
=========================

[](#bitcoin-address-validator)

[![Author](https://camo.githubusercontent.com/5660ca244b9dcf44b3d7795203c4cab7aaafa26dcc4499c8e347c1abd8b37942/687474703a2f2f696d672e736869656c64732e696f2f62616467652f666f6c6c6f772d406b69656c61626f6b6b69652d626c75652e7376673f6c6f676f3d74776974746572267374796c653d666c61742d737175617265)](https://twitter.com/kielabokkie)[![Build](https://camo.githubusercontent.com/c2107aef4c030ca0a8f4b13fe3e3564474e6b3f94b6828f27b4884ad18523bf2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6b69656c61626f6b6b69652f626974636f696e2d616464726573732d76616c696461746f722f74657374732f6d61737465723f7374796c653d666c61742d737175617265)](https://github.com/kielabokkie/bitcoin-address-validator/actions)[![Packagist Version](https://camo.githubusercontent.com/4ba0b61d35751569bea2264ab9c6853144762b7fd80d163d0e702a87e241ade2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b69656c61626f6b6b69652f626974636f696e2d616464726573732d76616c696461746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/kielabokkie/bitcoin-address-validator)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/677cac3d46996b13ef51582e67c144f374d29329f0008e5e4953fc4737bb236c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b69656c61626f6b6b69652f626974636f696e2d616464726573732d76616c696461746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/kielabokkie/bitcoin-address-validator)

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

Requirements
------------

[](#requirements)

- PHP &gt;= 7.3

PHPPackage Version7.xv1.08.xv2.0+Please note that taproot addresses are supported from v2.1 of this package.

Installation
------------

[](#installation)

Install the package via composer:

```
composer require kielabokkie/bitcoin-address-validator

```

Usage
-----

[](#usage)

First you instantiate the validator class:

```
$addressValidator = new \Kielabokkie\Bitcoin\AddressValidator;
```

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

```
$addressValidator->isValid('1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i');
```

Legacy (P2PKH) address:

```
$addressValidator->isPayToPublicKeyHash('1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i');
```

Segwit (P2SH) address:

```
$addressValidator->isPayToScriptHash('3ALJH9Y951VCGcVZYAdpA3KchoP9McEj1G');
```

Native segwit (bech32) address:

```
$addressValidator->isBech32('bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4');
```

Taproot (P2TR) address:

```
$addressValidator->isPayToTaproot('bc1pveaamy78cq5hvl74zmfw52fxyjun3lh7lgt44j03ygx02zyk8lesgk06f6');
```

### Testnet

[](#testnet)

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
$addressValidator->includeTestnet()->isBech32('bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4');
$addressValidator->includeTestnet()->isBech32('tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx');
```

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

```
// Invalid
$addressValidator->onlyTestnet()->isBech32('bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4');
// Valid
$addressValidator->onlyTestnet()->isBech32('tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx');
```

Testing
-------

[](#testing)

This package is tested against the test data of the official [bitcoin/bitcoin](https://github.com/bitcoin/bitcoin/tree/master/src/test/data) repo. If you come across an address that is not validated correctly please [open an issue](https://github.com/kielabokkie/bitcoin-address-validator/issues) for it.

Run the tests with:

```
composer test
```

Credits
-------

[](#credits)

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

- [bitwasp/bech32](https://github.com/Bit-Wasp/bech32) by [@afk11](https://github.com/afk11)
- [brooksyang/bech32m](https://github.com/BrooksYang/bech32m) by [BrooksYang](https://github.com/BrooksYang)
- [linusu/bitcoin-address-validator](https://github.com/LinusU/php-bitcoin-address-validator) by [@LinusU](https://github.com/LinusU)

All credit goes to the original authors.

Donate
------

[](#donate)

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

A donation would be much appreciated: `32vtWJSomccxQ6y1tgSwSHXN5PChpdYy27`

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance52

Moderate activity, may be stable

Popularity47

Moderate usage in the ecosystem

Community12

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 93.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~322 days

Total

5

Last Release

964d ago

Major Versions

v1.0.0 → v2.0.02020-12-12

PHP version history (3 changes)v1.0.0PHP ^7.1.3

v2.0.0PHP ^7.3|^8.0

v2.1.0PHP ^7.3|^7.4|^8.0|^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/7824402e192649e35e5fa208e52a2bd8cab2afa343388b513f15a1bced95e600?d=identicon)[kielabokkie](/maintainers/kielabokkie)

---

Top Contributors

[![kielabokkie](https://avatars.githubusercontent.com/u/1221750?v=4)](https://github.com/kielabokkie "kielabokkie (14 commits)")[![sh41](https://avatars.githubusercontent.com/u/6237786?v=4)](https://github.com/sh41 "sh41 (1 commits)")

---

Tags

addressbitcoinbitcoin-addressesbitcoin-validatorphpphp-libraryphp-packagesegwittaprootvalidatorvalidationaddressbitcoinbech32segwit

### Embed Badge

![Health badge](/badges/kielabokkie-bitcoin-address-validator/health.svg)

```
[![Health](https://phpackages.com/badges/kielabokkie-bitcoin-address-validator/health.svg)](https://phpackages.com/packages/kielabokkie-bitcoin-address-validator)
```

###  Alternatives

[respect/validation

The most awesome validation engine ever created for PHP

5.9k37.4M383](/packages/respect-validation)[opis/json-schema

Json Schema Validator for PHP

64736.9M186](/packages/opis-json-schema)[vlucas/valitron

Simple, elegant, stand-alone validation library with NO dependencies

1.6k4.4M128](/packages/vlucas-valitron)[intervention/validation

Additional validation rules for the Laravel framework

6826.7M8](/packages/intervention-validation)[proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rules, Messages, and FormRequest

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[wixel/gump

A fast, extensible &amp; stand-alone PHP input validation class that allows you to validate any data.

1.2k1.3M30](/packages/wixel-gump)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
