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.Net
ByteFlow.Net — Convert bytes ⇄ human-readable formats with SI, IEC, culture-aware, and customizable units. Zero dependencies.
1234567 → "1.23 MB")"2.5 GB" → 2684354560)TryParseHumanBytes (no exception)"1,5 MB" for cultures with comma decimal separators)Install via NuGet:
dotnet add package ByteFlow.Net
using ByteFlow;
// Basic conversion
long size = 1234567;
Console.WriteLine(size.ToHumanBytes()); // e.g. "1.18 MB" (default settings)
Console.WriteLine(size.ToHumanBytes(3)); // more decimals
// Parsing string to bytes
long bytes = "2.5 GB".ToBytes(); // default parsing (SI/IEC based on default)
Console.WriteLine(bytes);
// Safe parsing
if ("10 MB".TryParseHumanBytes(out var val))
{
Console.WriteLine(val); // prints bytes if successful
}
// Using IEC explicitly
Console.WriteLine(1536L.ToHumanBytes(2, UnitStandard.IEC)); // "1.50 KiB"
long val2 = "1.50 KiB".ToBytes(UnitStandard.IEC);
// Culture-aware parsing/formatting
var de = new System.Globalization.CultureInfo("de-DE");
Console.WriteLine((1500L).ToHumanBytes(2, UnitStandard.SI, de)); // "1,50 KB"
long val3 = "1,50 KB".ToBytes(UnitStandard.SI, de);
// Custom suffix sets
var custom = new[] { ("X", 1d), ("KX", 1000d), ("MX", 1000000d) };
string customStr = 5000L.ToHumanBytes(2, UnitStandard.SI, null, custom); // "5.00 KX"
long customBytes = "5 KX".ToBytes(UnitStandard.SI, null, custom);
Unit tests are under ByteFlow.Tests (xUnit).
Run them with:
dotnet test
Coverage is tracked via Codecov — current coverage: 100% ✅
While there are other “bytes to human readable” .NET libraries out there, very few (if any) offer the combined feature set that ByteFlow.Net does:
So this library aims to be a robust one-stop solution for byte-size formatting.
Contributions, issues, and feature requests are always welcome!
Feel free to open a discussion or a pull request.
If you enjoy using ByteFlow.Net, a GitHub star helps more than you’d think — it boosts visibility and helps others find it.
Licensed under the MIT License — see LICENSE.txt for details.