PHPackages                             brianium/nomnom - 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. brianium/nomnom

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

brianium/nomnom
===============

Simple file size conversion for PHP 5.3+

v1.1.1(11y ago)12119.0k↓33.3%1MITPHP

Since Aug 21Pushed 11y ago1 watchersCompare

[ Source](https://github.com/brianium/nomnom)[ Packagist](https://packagist.org/packages/brianium/nomnom)[ RSS](/packages/brianium-nomnom/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (5)Used By (1)

\#Nomnom [![Build Status](https://camo.githubusercontent.com/a2273ec034646db0884a921b6165aeb845db9a6bbe1efea280f50f12d7dd9dca/68747470733a2f2f7472617669732d63692e6f72672f627269616e69756d2f6e6f6d6e6f6d2e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/brianium/nomnom)

> Get it? Bytes? Bites?

Nomnom handles file size conversion for PHP 5.3+. It handles both binary (base 2) and metric (base 10) conversions. It provides a simple interface for converting between sizes of any similar base!

Usage
-----

[](#usage)

A Nomnom object is constructed with a "start" value that will be converted. Two methods are defined on this object: `from` and `to`. Each of these methods takes a metric or binary unit to convert from/to.

The `to` method takes an optional `precision` value to specify how many significant digits to keep in the result.

```
$nomnom = new Nomnom(1440000);

//metric conversion to 1.44
$mb = $nomnom->from('B')->to('MB', 2);

$nomnom = new Nomnom(1024);

//binary conversion to 1
$kb = $nomnom->from('KiB')->to('MiB');

//convert a file size
$filesize = new Filesize('/path/to/file.txt');
$mb = $filesize->to('MB');
```

As a convenience, Nomnom provides a factory method called `nom` and constants for the metric and binary units.

```
//returns 1.44
Nomnom::nom(1440000)->from(Nomnom::BYTES)->to(Nomnom::MB, 2);

//factory for Filesize
Nomnom::file('/path/to/file.txt')->to(Nomnom::MB);
```

Notes
-----

[](#notes)

'B' refers to bytes in either base 10 or base 2.

Nomnom will throw a `ConversionException` if the `from` and `to` methods contain units for different bases, i.e no `$nomnom->from('KiB')->to('MB');`

Nomnom requires the bcmath extension to handle greater precision.

Tests
-----

[](#tests)

To run the tests, make sure dependencies have been installed with `composer install --dev` and run:

```
vendor/bin/phpunit test/
```

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity66

Established project with proven stability

 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

Every ~144 days

Total

4

Last Release

4220d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

conversionfilesize

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/brianium-nomnom/health.svg)

```
[![Health](https://phpackages.com/badges/brianium-nomnom/health.svg)](https://phpackages.com/packages/brianium-nomnom)
```

###  Alternatives

[cuyz/valinor

Dependency free PHP library that helps to map any input into a strongly-typed structure.

1.5k9.2M108](/packages/cuyz-valinor)[florianv/swap

Exchange rates library for PHP

1.3k6.4M16](/packages/florianv-swap)[spatie/color

A little library to handle color conversions

38118.9M28](/packages/spatie-color)[php-units-of-measure/php-units-of-measure

A PHP library for converting between standard units of measure.

3123.4M20](/packages/php-units-of-measure-php-units-of-measure)[florianv/laravel-swap

Currency exchange rates library for Laravel and Lumen

3342.0M2](/packages/florianv-laravel-swap)[php-unit-conversion/php-unit-conversion

A fully PSR-4 compatible PHP library for converting between standard units of measure.

681.2M1](/packages/php-unit-conversion-php-unit-conversion)

PHPackages © 2026

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