Home

SizeParse3

sizeParse3 is a JavaScript utility function designed to convert human-readable file size strings into a numeric byte count. It accepts both decimal (SI) and binary (IEC) prefixes, enabling inputs such as "1.5 GB", "2 GiB", or "800 MB" to be interpreted as the corresponding number of bytes. The function is commonly used in configuration parsers, CLI tools, and applications that accept user-specified size limits or quotas.

SizeParse3 is the third iteration in the sizeParse family, offering improved robustness and flexibility over its

API and usage: sizeParse3(input, options) returns the number of bytes as a Number. Options may include base:

See also: sizeParse, unit parsing libraries, file size parsing in computing. This article describes a general-purpose

predecessors.
It
supports
a
wide
range
of
suffixes:
B,
KB,
MB,
GB,
TB,
PB
for
decimal
base
1000,
and
KiB,
MiB,
GiB,
TiB,
PiB
for
binary
base
1024.
It
is
locale-aware
regarding
decimal
separators
and
allows
optional
spaces
between
the
number
and
unit.
It
can
parse
integers
and
floating-point
values,
and
accepts
both
uppercase
and
lowercase
suffixes.
1000
or
1024;
allowWhitespace:
boolean;
locale:
string,
and
throwOnInvalid:
boolean.
Example:
sizeParse3("1.5GiB",
{
base:
1024
})
returns
1610612736.
If
the
input
is
invalid,
the
function
may
return
NaN
or
throw
an
error
depending
on
configuration.
parsing
utility
widely
used
in
JavaScript
environments
and
is
independent
of
a
specific
framework.