zetflake / number-to-words
Convert numbers and currency amounts to their written English words representation for Laravel.
v1.0.0
2026-09-16 15:05 UTC
Requires
- php: ^8.2
- illuminate/support: ^11.0|^12.0
Requires (Dev)
- laravel/pint: ^1.18
- orchestra/testbench: ^9.0|^10.0
- phpunit/phpunit: ^11.0
Suggests
- ext-intl: Enables locale-aware spelling via NumberFormatter. A pure PHP fallback is used when absent.
Provides
None
Conflicts
None
Replaces
None
README
Convert numbers and currency amounts into written English words. Built for the "Amount in words" line on invoices, proformas and receipts.
Uses PHP's ext-intl when available and falls back to a bundled pure PHP
speller that produces identical output when it isn't.
Installation
composer require zetflake/number-to-words
The service provider is auto-discovered. Publish the config if you want to change the defaults:
php artisan vendor:publish --tag=number-to-words-config
Usage
use Zetflake\NumberToWords\Facades\NumberToWords; NumberToWords::convert(1234); // "One thousand two hundred thirty-four" NumberToWords::currency(1500.50); // "One thousand five hundred shillings and fifty cents" NumberToWords::currency(1500.50, 'dollars', 'cents'); // "One thousand five hundred dollars and fifty cents" NumberToWords::case('upper')->convert(42); // "FORTY-TWO"
Or inject it:
use Zetflake\NumberToWords\NumberToWords; public function __construct(private NumberToWords $words) {}
Or use the helpers:
number_to_words(99); // "Ninety-nine" amount_in_words(99.25); // "Ninety-nine shillings and twenty-five cents"
In Blade:
<p>Amount in words: @amountInWords($invoice->total)</p> <p>Quantity: @numberToWords($item->quantity)</p>
From the CLI:
php artisan number-to-words 1234 php artisan number-to-words 1234.56 --currency
Notes
convert()truncates decimals. Usecurrency()if you need the fractional part.- Negative values are prefixed with "negative" rather than silently made positive.
- Integers up to quintillions are supported; beyond that the number is returned as-is.
- Set
use_intltofalsein the config to guarantee byte-identical output across servers regardless of whether the intl extension is installed.
Testing
composer install
composer test
License
MIT