Format a byte count to a human-readable file size string.
Uses binary units (1 KB = 1024 bytes) which is standard for file sizes.
Number of bytes
Number of decimal places (default: 2)
Formatted file size string (e.g., "1.5 MB")
formatFileSize(0); // "0 Bytes"formatFileSize(1024); // "1 KB"formatFileSize(1536); // "1.5 KB"formatFileSize(1048576); // "1 MB"formatFileSize(1073741824); // "1 GB"formatFileSize(1536, 0); // "2 KB" Copy
formatFileSize(0); // "0 Bytes"formatFileSize(1024); // "1 KB"formatFileSize(1536); // "1.5 KB"formatFileSize(1048576); // "1 MB"formatFileSize(1073741824); // "1 GB"formatFileSize(1536, 0); // "2 KB"
Format a byte count to a human-readable file size string.
Uses binary units (1 KB = 1024 bytes) which is standard for file sizes.