ByteFlow.Net is a zero-dependency .NET library for converting raw byte values to and from human-readable formats. Features: - Supports both IEC (KiB, MiB, GiB) and SI (KB, MB, GB) unit standards - Culture-aware parsing and formatting (e.g., 1.5 MB vs 1,5 MB) - Customizable suffix sets for non-standard or domain-specific units - Alignment/padding helpers for clean console and tabular output - Fully tested with 100% code coverage Ideal for developers needing clear, reliable byte size conversions in .NET applications — with no external dependencies.
$ dotnet add package ByteFlow.NetA lightweight .NET library for converting bytes into human-readable formats (KB, MB, GB, etc.) and back again.
1234567 → "1.18 MB")."2.5 GB" → 2684354560).TryParseHumanBytes.Install from NuGet:
dotnet add package ByteFlow.Netusing ByteFlowNet;
// Convert bytes to human-readable string
long size = 1234567;
Console.WriteLine(size.ToHumanBytes()); // "1.18 MB"
Console.WriteLine(size.ToHumanBytes(3)); // "1.177 MB"
// Parse string back into bytes
long bytes = "2.5 GB".ToBytes(); // 2684354560
Console.WriteLine(bytes);
// Safe parsing
if ("10 MB".TryParseHumanBytes(out var val))
{
Console.WriteLine(val); // 10485760
}Unit tests are included under the tests/ByteFlowNet.Tests project using xUnit.
Run them with:
dotnet testCode coverage reports are automatically uploaded to Codecov.
Current coverage: ~97–100% depending on build.
Contributions, issues, and feature requests are welcome!
Feel free to open a discussion or a pull request.
This project is licensed under the MIT License – see the LICENSE.txt file for details.