PHPackages                             wikimedia/base-convert - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. wikimedia/base-convert

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

wikimedia/base-convert
======================

Convert an arbitrarily-long string from one numeric base to another, optionally zero-padding to a minimum column width.

v2.0.2(3y ago)51.1M—1.5%14GPL-2.0-or-laterPHPPHP &gt;=7.2.9

Since Oct 29Pushed 2mo ago14 watchersCompare

[ Source](https://github.com/wikimedia/base-convert)[ Packagist](https://packagist.org/packages/wikimedia/base-convert)[ Docs](https://www.mediawiki.org/wiki/base_convert)[ RSS](/packages/wikimedia-base-convert/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (7)Versions (6)Used By (4)

[![Latest Stable Version](https://camo.githubusercontent.com/43ea703e358100b8b86d54f50b53b45ec9596d23989b273a04f82608f4723043/68747470733a2f2f706f7365722e707567782e6f72672f77696b696d656469612f626173652d636f6e766572742f762f737461626c652e737667)](https://packagist.org/packages/wikimedia/base-convert) [![License](https://camo.githubusercontent.com/ef091eab88e5bc68cf16ab1390c1b109ac23a48c420036def633fe55f6a061a8/68747470733a2f2f706f7365722e707567782e6f72672f77696b696d656469612f626173652d636f6e766572742f6c6963656e73652e737667)](https://packagist.org/packages/wikimedia/base-convert)

Improved base\_convert for PHP
==============================

[](#improved-base_convert-for-php)

PHP's `base_convert` function does not handle large numbers well. This library does, and can also optionally zero-pad to a minimum column width.

It is a drop-in replacement for base\_convert, supporting base 2 through 36, and has additional features for padding and case.

The gmp and bcmath extensions are optionally used for improved performance.

Additional documentation about the library can be found on [MediaWiki.org](https://www.mediawiki.org/wiki/base_convert).

Usage
-----

[](#usage)

```
// Using padding, outputs 01010
\Wikimedia\base_convert( 'a', '36', '2', '5' )
```

Running tests
-------------

[](#running-tests)

```
composer install --prefer-dist
composer test

```

History
-------

[](#history)

This library was first introduced in [MediaWiki 1.7](https://www.mediawiki.org/wiki/MediaWiki_1.7) ([r14777](https://www.mediawiki.org/wiki/Special:Code/MediaWiki/14777)), and overhauled in [MediaWiki 1.21](https://www.mediawiki.org/wiki/MediaWiki_1.21) ([9b9daadc46](https://gerrit.wikimedia.org/r/40552)). It was split out of the MediaWiki codebase and published as an independent library during the [MediaWiki 1.27](https://www.mediawiki.org/wiki/MediaWiki_1.27) development cycle.

---

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance57

Moderate activity, may be stable

Popularity44

Moderate usage in the ecosystem

Community25

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~599 days

Total

5

Last Release

1459d ago

Major Versions

v1.0.1 → v2.0.02018-10-21

PHP version history (3 changes)v1.0.0PHP &gt;=5.3.3

v2.0.0PHP &gt;=5.6.99

v2.0.1PHP &gt;=7.2.9

### Community

Maintainers

![](https://www.gravatar.com/avatar/b94d9718c06ec7c3fd7a104bc44966fb7464b9ec7411582343ea35a7a6a85f08?d=identicon)[mediawiki](/maintainers/mediawiki)

![](https://www.gravatar.com/avatar/716c86d71cbf921e7912a505f89d799de398fc0a3af0bd4c8862834b2d642bd7?d=identicon)[wikimedia](/maintainers/wikimedia)

---

Top Contributors

[![reedy](https://avatars.githubusercontent.com/u/67615?v=4)](https://github.com/reedy "reedy (11 commits)")[![jdforrester](https://avatars.githubusercontent.com/u/881572?v=4)](https://github.com/jdforrester "jdforrester (10 commits)")[![legoktm](https://avatars.githubusercontent.com/u/81392?v=4)](https://github.com/legoktm "legoktm (7 commits)")[![umherirrender](https://avatars.githubusercontent.com/u/1174884?v=4)](https://github.com/umherirrender "umherirrender (6 commits)")[![Krinkle](https://avatars.githubusercontent.com/u/156867?v=4)](https://github.com/Krinkle "Krinkle (1 commits)")[![DannyS712](https://avatars.githubusercontent.com/u/46829944?v=4)](https://github.com/DannyS712 "DannyS712 (1 commits)")[![Daimona](https://avatars.githubusercontent.com/u/38216014?v=4)](https://github.com/Daimona "Daimona (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/wikimedia-base-convert/health.svg)

```
[![Health](https://phpackages.com/badges/wikimedia-base-convert/health.svg)](https://phpackages.com/packages/wikimedia-base-convert)
```

PHPackages © 2026

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