Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Number To Words

Number To Words Laravel Package

kwn/number-to-words

Convert numbers and currency amounts to words in PHP. Supports multiple languages via RFC 3066 identifiers, with number and currency transformers. Simple API: create transformers or use static calls to render values like 5120 as “five thousand one hundred twenty”.

View on GitHub
Deep Wiki
Context7

Number to string standalone PHP library with i18n. Drivers for numbers and currency included.

Frequently asked questions about Number To Words
How do I install kwn/number-to-words in a Laravel project?
Run `composer require kwn/number-to-words` in your project root. The package integrates seamlessly with Laravel’s service container and requires no additional configuration. For Hungarian support, ensure you’re on version ^3.0.1 or later.
Does this package support Laravel Blade directives out of the box?
Yes. Use `@numberToWords($value, 'hu')` in Blade templates for Hungarian or any other supported locale. The package auto-detects Laravel’s app locale if no language is specified, making it ideal for dynamic multilingual apps.
What Laravel versions are compatible with kwn/number-to-words?
The package works with Laravel 8.x, 9.x, and 10.x. It requires PHP 7.4 or higher. No Laravel-specific dependencies mean it won’t conflict with your existing setup, and the Hungarian fix in 3.0.1 is fully backward-compatible.
How do I convert currency amounts (e.g., $51.20) to words in Hungarian?
Use the currency transformer: `$transformer = app('numberToWords')->getCurrencyTransformer('hu'); $transformer->toWords(51.20, 'USD');`. For floating-point values, multiply by 100 first (e.g., 5120 cents) to avoid precision issues. The package handles currency symbols and locales automatically.
Are there any known issues with the Hungarian (hu) locale after the 3.0.1 fix?
The fix resolves basic number-to-words conversion for Hungarian, but edge cases like large numbers (e.g., 1,000,000 → ‘egy millió’) or negative values may require manual testing. Validate outputs for your use case, especially in financial or legal contexts where accuracy is critical.
Can I use this package in Laravel API responses or PDF generation?
Absolutely. For APIs, add the transformed value to your DTOs: `return ['amount_words_hu' => app('numberToWords')->transformNumber('hu', $amount)];`. For PDFs (e.g., with `spatie/laravel-pdf`), ensure the Hungarian text renders correctly by testing with `laravel-dompdf` or similar libraries.
How do I test this package in my Laravel application?
Add a test class like `NumberToWordsHungarianTest` to your suite. Example: `$this->assertEquals('ötven', app('numberToWords')->transformNumber('hu', 50));`. Test critical numbers (0, 1, 100, 1,000,000) and edge cases. Use Laravel’s `phpunit` to automate checks in CI.
What are the alternatives to kwn/number-to-words for Laravel?
Alternatives include `mike42/escpos-php` (for receipts) or `spatie/array-to-xlsx` (for spreadsheets), but neither offers i18n number-to-words conversion. For standalone libraries, `number/number-to-words` is another option, but it lacks Laravel integration and Hungarian support. This package is the most feature-complete for multilingual apps.
Should I pin the package version to ^3.0.1 to avoid future updates?
Pinning to ^3.0.1 is recommended if you rely on the Hungarian fix and want to avoid potential breaking changes in minor updates. Monitor the GitHub repo for updates, but the package’s modular design means fixes are typically isolated to specific locales.
How do I handle floating-point numbers (e.g., 50.99) in currency conversion?
Multiply the amount by 100 to convert to the smallest currency unit (e.g., cents). Use `$transformer->toWords(5099, 'USD')` for 50.99 USD. The package doesn’t automatically scale floating-point values, so pre-process the input to avoid precision errors in locales like Hungarian.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky