PHPackages                             shacky/number-to-words - 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. shacky/number-to-words

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

shacky/number-to-words
======================

Multi language standalone PHP number to words converter. Fully tested, open for extensions and new languages.

1.0(5mo ago)00MITPHPPHP &gt;=7.4

Since Jan 18Pushed 5mo agoCompare

[ Source](https://github.com/shacky/number-to-words)[ Packagist](https://packagist.org/packages/shacky/number-to-words)[ RSS](/packages/shacky-number-to-words/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

PHP Number to words converter
=============================

[](#php-number-to-words-converter)

[![Latest Stable Version](https://camo.githubusercontent.com/fa535ca00f90e9439d7aabdfba6529746f6c28ab9d5182be40b099adeb26fa47/68747470733a2f2f706f7365722e707567782e6f72672f736861636b792f6e756d6265722d746f2d776f7264732f762f737461626c65)](https://packagist.org/packages/shacky/number-to-words)

Welcome to `number-to-words`, a PHP utility that seamlessly transforms numeric values into their corresponding words. Effortlessly convert numbers, such as 123, into expressive and readable formats like "one hundred and twenty-three" with just a few lines of code.

Based on work: [kwn/number-to-words](https://github.com/kwn/number-to-words)

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

[](#installation)

Add package to your composer.json by running:

```
$ composer require shacky/number-to-words

```

Usage
-----

[](#usage)

There are two types of number-to-words transformation: number and currency. In order to use a relevant transformer for specific language create an instance of `NumberToWords` class and call a method that creates a new instance of the desired transformer;

### Number Transformer

[](#number-transformer)

Create a transformer for specific language using the `getNumberTransformer('lang')` method:

```
use NumberToWords\NumberToWords;

// create the number to words "manager" class
$numberToWords = new NumberToWords();

// build a new number transformer using the RFC 3066 language identifier
$numberTransformer = $numberToWords->getNumberTransformer('en');
```

Transformer can be used by passing in numeric values to the `toWords()` method:

```
$numberTransformer->toWords(5120); // outputs "five thousand one hundred twenty"
```

It can be also used with a static method:

```
NumberToWords::transformNumber('en', 5120); // outputs "five thousand one hundred twenty"
```

### Currency Transformer

[](#currency-transformer)

Creating a currency transformer works just like a number transformer.

```
use NumberToWords\NumberToWords;

// create the number to words "manager" class
$numberToWords = new NumberToWords();

// build a new currency transformer using the RFC 3066 language identifier
$currencyTransformer = $numberToWords->getCurrencyTransformer('en');
```

Then it can be used passing in numeric values for amount and ISO 4217 currency identifier to the `toWords()` method:

```
$currencyTransformer->toWords(5099, 'USD'); // outputs "fifty dollars ninety nine cents"
```

It can be also used with a static method:

```
NumberToWords::transformCurrency('en', 5099, 'USD'); // outputs "fifty dollars ninety nine cents"
```

Note: The Currency Transformer within this library processes integers; ensure your input amounts are in whole numbers by multiplying any float values by 100 before transformation. For instance, transform 45.67 by using 4567 as the input for accurate currency conversion.

Available locale
----------------

[](#available-locale)

LanguageIdentifierNumberCurrencyAliasAlbanianal++Arabicar++Azerbaijaniaz++Belgian Frenchfr\_BE+-Brazilian Portuguesept\_BR++Bulgarianbg++Czechcs+-Danishdk++Dutchnl+-Englishen++Estonianet+-Frenchfr++fr\_FRGeorgianka++Germande++Hebrewhe++Hungarianhu++Indonesianid++Italianit+-Kurdishku+-Lithuanianlt++Latvianlv++Macedonianmk+-Malayms++Persianfa+-Polishpl++Portuguesept++pt\_PTRomanianro++Serbiansr++Slovaksk++Spanishes++Russianru++Swahilisw++Swedishsv+-Turkishtr++Turkmentk++Ukrainianua++Uzbekuz++Yorubayo++Adding a new language
---------------------

[](#adding-a-new-language)

New languages should be built with `NumberTransformerBuilder` and language-specific components under `src/Language//`.

- Dictionary: implement `Dictionary` and expose zero/minus, units, teens, tens, hundreds, and exponent names. Reuse any existing legacy data. Keep word separator and conjunction in the dictionary for consistent joins.
- Triplet transformer: implement `TripletTransformer` or `PowerAwareTripletTransformer` to render 0-999. Use grammatical gender helpers if the language needs gender-specific forms.
- Exponent handler: add an `ExponentInflector` (or `PowerAwareExponentInflector`) to inflect thousand/million/etc. by number. Use `ExponentGetter` only for fixed names.
- Currency coverage: for each language dictionary, include all currencies present in `EnglishDictionary::$currencyNames`, with localized singular/plural names for major/minor units. You can use source translations from the canonical Google currencies CSV (`https://developers.google.com/public-data/docs/canonical/currencies_csv?hl=`).
- Transformer wiring: create `NumberTransformer/NumberTransformer.php` and, if needed, `CurrencyTransformer/CurrencyTransformer.php` using `NumberTransformerBuilder` with the language dictionary, triplet transformer, and exponent inflector. For currency, split amounts with `CurrencySubunitSplitter` and declense currency nouns by number/gender.
- Tests: add or update language-specific tests under `tests/NumberTransformer/` and `tests/CurrencyTransformer/`. Run `vendor/bin/phpunit --filter ` during development and `vendor/bin/phpunit --no-coverage` before submitting.

Contributors
------------

[](#contributors)

Some transformers were ported from the `pear/Numbers_Words` library. Others were created by [contributors](https://github.com/kwn/number-to-words/graphs/contributors). Thank you!

Version 2.x - BC and major changes
----------------------------------

[](#version-2x---bc-and-major-changes)

- Dropped support for PHP &lt;7.4.
- Added typehints for `NumberTransformer` and `CurrencyTransformer` interfaces. Now both accept integer numbers only (Albanian language might be affected).
- Added support for PSR12.

Questions and answers
---------------------

[](#questions-and-answers)

**Q: What should I do if I encounter a bug while using the library?**

A: If you come across a bug, please open an issue on our GitHub repository. As I may not be proficient in all languages, we encourage users to submit fixes and collaborate to enhance the library's functionality.

**Q: My language is missing. Could it be added?**

A: There's a high chance I don't know your language. Feel free to implement the missing language and open a pull request. You can use the existing languages as a reference.

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance70

Regular maintenance activity

Popularity0

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 60.6% 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

Unknown

Total

1

Last Release

168d ago

### Community

Maintainers

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

---

Top Contributors

[![kwn](https://avatars.githubusercontent.com/u/3968616?v=4)](https://github.com/kwn "kwn (223 commits)")[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (51 commits)")[![shacky](https://avatars.githubusercontent.com/u/6030720?v=4)](https://github.com/shacky "shacky (21 commits)")[![Zehir](https://avatars.githubusercontent.com/u/845225?v=4)](https://github.com/Zehir "Zehir (14 commits)")[![janhartigan](https://avatars.githubusercontent.com/u/580052?v=4)](https://github.com/janhartigan "janhartigan (7 commits)")[![popovserhii](https://avatars.githubusercontent.com/u/1991183?v=4)](https://github.com/popovserhii "popovserhii (5 commits)")[![IgorZavaleev](https://avatars.githubusercontent.com/u/25030672?v=4)](https://github.com/IgorZavaleev "IgorZavaleev (4 commits)")[![goodot](https://avatars.githubusercontent.com/u/10999902?v=4)](https://github.com/goodot "goodot (3 commits)")[![veguss](https://avatars.githubusercontent.com/u/35691298?v=4)](https://github.com/veguss "veguss (3 commits)")[![shahonseven](https://avatars.githubusercontent.com/u/372461?v=4)](https://github.com/shahonseven "shahonseven (3 commits)")[![ickbinhier](https://avatars.githubusercontent.com/u/2810904?v=4)](https://github.com/ickbinhier "ickbinhier (3 commits)")[![cristiangomeze](https://avatars.githubusercontent.com/u/19762300?v=4)](https://github.com/cristiangomeze "cristiangomeze (3 commits)")[![andreybolonin](https://avatars.githubusercontent.com/u/2576509?v=4)](https://github.com/andreybolonin "andreybolonin (2 commits)")[![CreepPork](https://avatars.githubusercontent.com/u/1590711?v=4)](https://github.com/CreepPork "CreepPork (2 commits)")[![iamdual](https://avatars.githubusercontent.com/u/3048763?v=4)](https://github.com/iamdual "iamdual (2 commits)")[![kongulov](https://avatars.githubusercontent.com/u/33090344?v=4)](https://github.com/kongulov "kongulov (2 commits)")[![leonardjke](https://avatars.githubusercontent.com/u/22217360?v=4)](https://github.com/leonardjke "leonardjke (2 commits)")[![pudovmaxim](https://avatars.githubusercontent.com/u/5713098?v=4)](https://github.com/pudovmaxim "pudovmaxim (2 commits)")[![samnela](https://avatars.githubusercontent.com/u/1852108?v=4)](https://github.com/samnela "samnela (2 commits)")[![xeux](https://avatars.githubusercontent.com/u/587394?v=4)](https://github.com/xeux "xeux (2 commits)")

---

Tags

moneycurrencystringwordsnumbersnumberto

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/shacky-number-to-words/health.svg)

```
[![Health](https://phpackages.com/badges/shacky-number-to-words/health.svg)](https://phpackages.com/packages/shacky-number-to-words)
```

###  Alternatives

[kwn/number-to-words

Multi language standalone PHP number to words converter. Fully tested, open for extensions and new languages.

4375.4M23](/packages/kwn-number-to-words)[cknow/laravel-money

Laravel Money

1.0k4.8M31](/packages/cknow-laravel-money)

PHPackages © 2026

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