Skip to content

formatBytes

formatBytes(bytes): string

Defined in: packages/core/src/media/utils.ts:18

Formats byte count into human-readable file size.

Converts raw byte count into appropriate units (B, KB, MB, GB, TB) with sensible precision for each scale.

number

File size in bytes

string

Formatted string with unit (e.g. “248 KB”, “1.4 MB”)

formatBytes(1024) // "1 KB"
formatBytes(1536) // "1.5 KB"
formatBytes(1048576) // "1 MB"
formatBytes(248000) // "242.2 KB"