
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
data-size-parser
Advanced tools
Parse human-readable data sizes like 10MB, 2gb, and 1.5 TiB into bytes.
A tiny, practical parser for human-readable data sizes.
This package converts values like 10MB, 2gb, 512 KiB, and 1.5 TiB into bytes. It is designed to be small, predictable, and easy to use in scripts, CLIs, data tooling, and storage-related workflows.
It can be used as both a practical utility and a lightweight reference for normalizing storage size inputs.
Human-readable data sizes appear everywhere.
Configuration files, CLI flags, dashboards, logs, APIs, and documentation often represent storage sizes as strings. Those strings are easy for people to read, but they are not immediately useful for systems that need exact byte values.
A parser solves that boundary problem.
Instead of writing ad hoc conversion logic in every project, data-size-parser provides a single, explicit way to interpret common decimal and binary size units.
The parser supports:
B, byte, bytesKB, MB, GB, TB, PBKiB, MiB, GiB, TiB, PiBExamples:
10MB → 100000002gb → 2000000000512 KiB → 5242881.5 TiB → 1649267441664npm install data-size-parser
import { parseDataSize } from "data-size-parser";
parseDataSize("10MB");
// 10000000
parseDataSize("2gb");
// 2000000000
parseDataSize("512 KiB");
// 524288
parseDataSize("1.5 TiB");
// 1649267441664
parseDataSize(input)Parses a human-readable data size string and returns the size in bytes as an integer.
import { parseDataSize } from "data-size-parser";
const bytes = parseDataSize("256MB");
// 256000000
tryParseDataSize(input)Attempts to parse a human-readable data size string and returns null instead of throwing when parsing fails.
import { tryParseDataSize } from "data-size-parser";
tryParseDataSize("64GiB");
// 68719476736
tryParseDataSize("not-a-size");
// null
formatSupportedUnits()Returns a list of supported unit labels.
import { formatSupportedUnits } from "data-size-parser";
formatSupportedUnits();
// ["B", "KB", "MB", "GB", "TB", "PB", "KiB", "MiB", "GiB", "TiB", "PiB"]
This project is intentionally minimal.
It focuses on one job: turning human-readable data size strings into byte values without introducing unnecessary complexity.
The design emphasizes:
This project does not attempt to:
Mbps or Kibit.It is focused only on parsing storage size strings into bytes.
parseDataSize("100") is treated as bytes.Future extensions may include:
GitHub: https://github.com/brandonhimpfen/data-size-parser
MIT
FAQs
Parse human-readable data sizes like 10MB, 2gb, and 1.5 TiB into bytes.
We found that data-size-parser demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.