PHP Classes


Recommend this page to a friend!
  Classes of Ankit Jain   PHP File Size Human Readable   Download  
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: PHP File Size Human Readable
Format files in terms of B, KB, MB, GB, TB
Author: By
Last change: Release v1.0
Added Readme
Added featues
Date: 4 years ago
Size: 1,724 bytes


Class file image Download

About prettysize

prettysize was created by, and is maintained by Ankit Jain, and is a helper utility to provide pretty printed file sizes.

Build Status Coverage Status Latest Stable Version

Installation & Usage

> Requires PHP 7.1+

Require prettysize using Composer:

composer require ankitjain28may/prettysize


Pretty::pretty($size, $nospace, $one, $places);

  $size : Size in bytes to be converted (Required)
  $nospace : Remove space from the output (Default - false)
  $one : Single character for the size (Default - false)
  $places : Number of decimal places to return (Default - 1)

use Ankitjain28may\Prettysize\Pretty;

$size = Pretty::pretty(1024);
// $size = "1.0 kB"

$size = Pretty::pretty(1024, true, true, 2);
// $size = "1.00k"

$size = Pretty::pretty(1024, ['nospace' => true, 'one' => true, 'places' => 5]);
// $size = "1.00000k"


Thank you for considering to contribute to prettysize. You can also follow the twitter account for latest announcements or just come say hi!: @ankitjain28may


prettysize is an open-sourced library licensed under the MIT license.