PHPackages                             l1nnah/file-size - 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. l1nnah/file-size

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

l1nnah/file-size
================

A library to display and parse readable file sizes

v1.0.0(11mo ago)011MITPHPCI passing

Since Jun 14Pushed 11mo agoCompare

[ Source](https://github.com/tonsoo/filesize)[ Packagist](https://packagist.org/packages/l1nnah/file-size)[ RSS](/packages/l1nnah-file-size/feed)WikiDiscussions main Synced 1mo ago

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

📦 FileSize — Human-friendly file size handling for PHP
======================================================

[](#-filesize--human-friendly-file-size-handling-for-php)

[![Latest Version on Packagist](https://camo.githubusercontent.com/2997406170b09f62eae8950c351e39450d0378caa0a9314dc836096904d9acd9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c316e6e61682f66696c652d73697a652e737667)](https://packagist.org/packages/l1nnah/file-size)[![Tests](https://camo.githubusercontent.com/b26789e82bd982d8a41a829794e21851dcf709ad2d8e2563b602659db24a3f35/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f746f6e736f6f2f66696c6573697a652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e)](https://github.com/tonsoo/filesize/actions)[![License](https://camo.githubusercontent.com/8e6199a9a2ea4d9672d31469bd061b810ed98ada6ba6276cce1b3d5ff31378e6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f746f6e736f6f2f66696c6573697a652e737667)](https://github.com/tonsoo/filesize/blob/main/LICENSE)

A lightweight and extensible PHP library to parse, format, and convert file sizes in a human-readable and localized way.

🚀 Features
----------

[](#-features)

- Convert bytes to human-readable formats (KB, MB, GB, etc.);
- Format file sizes with custom decimal and thousand separators;
- Parse strings like `"123.45 MB"` or `"1.234,56 KB"` into bytes;
- Multi-locale support with optional Laravel integration;
- Fully tested with PHPUnit.

📥 Installation
--------------

[](#-installation)

```
composer require l1nnah/filesize
```

🔧 Usage
-------

[](#-usage)

Converting bytes to human-readable format:

```
use L1nnah\FileSize\FileSizeConverter;
use L1nnah\FileSize\FileSizeUnits;

$valueInBytes = 123456;
$converter = new FileSizeConverter($valueInBytes);
$readable = $converter->convertTo(FileSizeUnits::KB);

echo $readable->toFixed(2); // Expected: "120.56 KB"
```

---

Parsing from human-readable string:

```
use L1nnah\FileSize\FileSizeConverter;

$converter = FileSizeConverter::fromString("1.234,56 MB");
echo $converter->sizeInBytes; // Expected: "1294467072"
```

✅ Testing
---------

[](#-testing)

PHPUnit was used for testing with the commands:

```
vendor/bin/phpunit tests/FileSizeTest.php
vendor/bin/phpunit tests/FileSizeFromStringTest.php
```

📫 Credits
---------

[](#-credits)

Developed by **tonsoo** and published under the nickname of **l1nnah**.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance52

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

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

338d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/32c5f40ac08285ef9e848f0d7bc76d30cc427d3670c272e3b1151e0724a85898?d=identicon)[tonsoo](/maintainers/tonsoo)

---

Top Contributors

[![tonsoo](https://avatars.githubusercontent.com/u/81568701?v=4)](https://github.com/tonsoo "tonsoo (4 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/l1nnah-file-size/health.svg)

```
[![Health](https://phpackages.com/badges/l1nnah-file-size/health.svg)](https://phpackages.com/packages/l1nnah-file-size)
```

###  Alternatives

[phenx/php-font-lib

A library to read, parse, export and make subsets of different types of font files.

1.8k154.8M51](/packages/phenx-php-font-lib)[hubertnnn/laravel-nova-field-dynamic-select

A Laravel Nova field.

22148.1k](/packages/hubertnnn-laravel-nova-field-dynamic-select)

PHPackages © 2026

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