std.conv.bytes_human

std.conv

bytes_human(size) -> formatted

Format a byte count as a human-readable string with units

Selects the largest unit for which size is at least 1 unit: TB (≥ 1024⁴), GB (≥ 1024³), MB (≥ 1024²), KB (≥ 1024). Values below 1024 are returned as "N B" (no decimal). All other values are formatted as "%.2f UNIT" (two decimal places).