ByteFlow.Net 0.2.0

dotnet add package ByteFlow.Net --version 0.2.0
                    
NuGet\Install-Package ByteFlow.Net -Version 0.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ByteFlow.Net" Version="0.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ByteFlow.Net" Version="0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="ByteFlow.Net" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ByteFlow.Net --version 0.2.0
                    
#r "nuget: ByteFlow.Net, 0.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ByteFlow.Net@0.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ByteFlow.Net&version=0.2.0
                    
Install as a Cake Addin
#tool nuget:?package=ByteFlow.Net&version=0.2.0
                    
Install as a Cake Tool

<p align="center"> <img src="https://raw.githubusercontent.com/AndrewClements84/ByteFlow.Net/master/assets/logo.png" alt="ByteFlow.Net Logo" width="200"/> </p>

ByteFlow.Net

Build codecov NuGet Version NuGet Downloads License: MIT GitHub Repo stars

ByteFlow.Net — Convert bytes ⇄ human-readable formats with SI, IEC, culture-aware, and customizable units. Zero dependencies.


✨ Features

  • Convert raw byte counts into human-readable strings (e.g. 1234567 → "1.23 MB")
  • Parse human-readable strings back into bytes ("2.5 GB" → 2684354560)
  • Safe parsing via TryParseHumanBytes (no exception)
  • Support for both IEC (KiB, MiB, GiB) and SI (KB, MB, GB) unit standards
  • Culture-aware parsing/formatting (e.g. "1,5 MB" for cultures with comma decimal separators)
  • Customizable suffix sets (allow defining your own unit names/factors)
  • Alignment/padding helpers for nicely formatted output in tables or logs
  • Fully tested with 100% code coverage
  • Zero external dependencies — pure C#

📦 Installation

Install via NuGet:

dotnet add package ByteFlow.Net

🚀 Usage

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 & Code Coverage

Unit tests are under ByteFlow.Tests (xUnit).
Run them with:

dotnet test

Coverage is tracked via Codecov — current coverage: 100%


🧭 Alternatives / Comparisons

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:

  • Support for both IEC and SI
  • Culture-aware parsing/formatting
  • Fully customizable suffix sets
  • Alignment/padding helpers
  • Zero dependencies
  • Complete test coverage

So this library aims to be a robust one-stop solution for byte-size formatting.


🤝 Contributing

Contributions, issues, and feature requests are always welcome!
Feel free to open a discussion or a pull request.


⭐ Support

If you enjoy using ByteFlow.Net, a GitHub star helps more than you’d think — it boosts visibility and helps others find it.


📄 License

Licensed under the MIT License — see LICENSE.txt for details.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.2.0 148 10/3/2025
0.1.1 177 10/1/2025
0.1.0 170 10/1/2025