Skip to content

Function: formatFileSize()

formatFileSize(bytes): string

Formats byte values into human-readable file sizes

number | undefined

The file size in bytes

string

Formatted string (e.g., “1.5 KB”, “3.2 MB”)

formatFileSize(512) // "512 B"
formatFileSize(1536) // "1.5 KB"
formatFileSize(2621440) // "2.5 MB"