encodes the byte array ba as a Base64 string.


encodes using the specified encoding.


  • In BaseEncode[ba], ba should be a ByteArray object.
  • Available encodings include:
  • "Base16"hexadecimal representation of byte values
    "Base64"default Base64 as described in the internet standard recommendation RFC 4648
    "Base85ASCII"Ascii85 or a85 encoding, with the "z shortcut"


open allclose all

Basic Examples  (2)

Encode a byte array:

Encode a byte array using using the Ascii85 encoding:

Scope  (2)

Encode the bytes 1 through 12:

The bytes can be recovered using BaseDecode:

Convert byte values to hexadecimal pairs:

Properties & Relations  (10)

The default encoding is "Base64":

The string returned by BaseEncode[ba] and BaseEncode[ba,"Base64"] has length divisible by 4:

Padding will be added, if necessary:

The "Base16" format uses two characters for each byte value:

"Base64" encodes up to three bytes in each block of four characters:

"Base85ASCII" can encode four bytes in a block of five characters:

There is no padding to yield a complete block:

As a special rule, "Base85ASCII" will encode four consecutive zero bytes using the single character z:

BaseEncode is the inverse of BaseDecode:

BaseEncode encodes binary data as a Base64 string:

The export format "Base64" encodes the string representation of an expression converted to bytes:

Achieve the same result with BaseEncode, ToString and ByteArrayToString:

BaseEncode converts a sequence of bytes to a sequence of characters:

IntegerString converts integers to a base-64 representation using the alphabet of Base64:

BaseEncode converts the "ByteArray" format of Hash to its "Base64Encoding" format:

ByteArray uses Base64 encoding of its data in InputForm:

Wolfram Research (2018), BaseEncode, Wolfram Language function, (updated 2020).


Wolfram Research (2018), BaseEncode, Wolfram Language function, (updated 2020).


Wolfram Language. 2018. "BaseEncode." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020.


Wolfram Language. (2018). BaseEncode. Wolfram Language & System Documentation Center. Retrieved from


@misc{reference.wolfram_2024_baseencode, author="Wolfram Research", title="{BaseEncode}", year="2020", howpublished="\url{}", note=[Accessed: 20-June-2024 ]}


@online{reference.wolfram_2024_baseencode, organization={Wolfram Research}, title={BaseEncode}, year={2020}, url={}, note=[Accessed: 20-June-2024 ]}