Everything you need for file size handling
Built for .NET developers who want clean, reliable and zero-dependency file size utilities.
Unit Conversion
Convert between any file size units: Bytes, KB, MB, GB, TB, PB, EB — with full IEC binary prefix support (KiB, MiB, GiB, TiB, PiB, EiB).
Smart Formatting
Format file sizes as human-readable strings with customizable decimal precision and cultural number formatting.
Auto Unit Detection
GetBestUnit automatically selects the most appropriate unit for any byte value, traditional or IEC.
Extension Methods
Ergonomic double and long extension methods — ToFormattedSize, FormatBestSize, GetBestUnit — for minimal boilerplate.
Dependency Injection
IValiFileSize interface for clean DI registration. Stateless singleton-safe implementation.
Multi-Framework
Targets netstandard2.0, netstandard2.1, net6.0, net7.0, net8.0, net9.0. Zero external dependencies.
Simple, expressive API
Auto-detect units, format sizes, convert between units — all with a clean, chainable API.
// Auto-detect best unitvar vfs = new ValiFileSize();string result = vfs.FormatBestSize(1_500_000_000); // "1.40 GB"// Extension methodsstring formatted = 1_500_000_000.0.FormatBestSize(); // "1.40 GB"// IEC prefixesstring iec = vfs.FormatBestSize(1_500_000_000, useIec: true); // "1.40 GiB"// Explicit conversiondouble kb = vfs.Convert(1, FileSizeUnit.Megabytes, FileSizeUnit.Kilobytes); // 1024