
How to Show Human-Readable File Sizes in PHP and Laravel
Turn byte counts into sizes like 1.5 MB in PHP and Laravel, choose between decimal KB and binary KiB, and avoid the rounding bug in the usual snippet.
Turn 1250000 into 1.3M, 1536 bytes into 1.5 KiB, 3661 seconds into 1 hour 1 minute 1 second and 1234.5 into USD 1,234.50, with one static call and the same output on every machine.
Each line is released for the versions in its row, read from that release's composer.json. Pick the line that matches your project; a combination not listed isn't supported. Find the right line of every package for your project.
| Line | Latest release | PHP | Status | Docs |
|---|---|---|---|---|
| v8.5.x | v8.5.2 Oct 11, 2026 | 8.5 | Current | Docs: Read the v8.5.x docs |
| v8.4.x | v8.4.2 Oct 11, 2026 | 8.4 | Maintained | Docs: Read the v8.4.x docs |
| v8.3.x | v8.3.2 Oct 11, 2026 | 8.3 | Maintained | Docs: Read the v8.3.x docs |
| v8.2.x | v8.2.2 Oct 11, 2026 | 8.2 | Maintained | Docs: Read the v8.2.x docs |
| v8.1.x | v8.1.2 Oct 11, 2026 | 8.1 | MaintainedPHP 8.1 no longer gets security fixes | Docs: Read the v8.1.x docs |
| v8.0.x | v8.0.3 Oct 11, 2026 | 8.0 | MaintainedPHP 8.0 no longer gets security fixes | Docs: Read the v8.0.x docs |
From the package's releases and its GitHub Actions. A passing run means the test suite passed on develop, on every PHP version it supports; it isn't a security review, and each release line has its own runs on GitHub. Checked hourly.
One static call per value, wherever you render it.
1use Pharaonic\Readable\{Bytes, Duration, Money, Number};2 3Number::compact(1250000); // "1.3M"4Number::percentage(0.756, 1); // "75.6%"5Number::ordinal(21); // "21st"6Bytes::format(1536, binary: true); // "1.5 KiB"7Money::format(1234.5, 'USD'); // "USD 1,234.50"8Money::format(1234.5, 'EUR', locale: 'de_DE'); // "1.234,50 €"9Duration::format(90061, parts: 2); // "1 day 1 hour"Six focused classes with static methods. No setup, no state, no framework.
Grouped thousands, 1.2M-style compact numbers, percentages, ordinals and numbers spelled out in words.
SI KB or binary KiB, never mixed, plus Bytes::parse('10 MB') to go back to an integer.
ISO 4217 codes with the right minor units, so JPY has no decimals and KWD has three.
Seconds or two dates to 2 days 4 hours, with long or short units and a parts limit.
Pass a locale such as de_DE to use Intl. Leave it out for a deterministic English formatter.
Half-up rounding, carry-over to the next unit and no -0.00, on every PHP version.
Practical guides that use PHP Readable, or solve the problem it was built for.

Turn byte counts into sizes like 1.5 MB in PHP and Laravel, choose between decimal KB and binary KiB, and avoid the rounding bug in the usual snippet.
Quick answers about installing and using Readable.
Human-friendly formatting for plain PHP. Turn numbers, byte sizes, money and durations into readable text, with predictable output and optional Intl locales. It's a free, open-source PHP package by Pharaonic.
Run composer require pharaonic/php-readable in your project's root directory.
The latest release requires PHP 8.5.
No. Without a locale, every formatter uses a built-in English formatter that gives the same output on every machine. You only need ext-intl when you pass a locale such as de_DE or ar_EG.
Yes. The classes are plain static methods with no framework dependency, no configuration and no global state, so you can call them from any PHP code.
Bytes::format() uses SI units (KB, MB) by default. Pass binary: true for IEC units (KiB, MiB), where 1 KiB is 1024 bytes. The two are never mixed.Yes. Readable is open source under the MIT license, so you can use it in personal and commercial projects.
Read the Readable documentation for installation, usage and examples.
Open an issue or a pull request on GitHub, or ask in the Pharaonic Discord.
Read the full documentation for installation, locales, numbers, byte sizes, money, durations, string and array helpers, the complete API reference and real-world examples.