Docly Developers
Function Updated 23 Oct 2026

base64(data)

Converts data to base64 encoded string.

Parameters

datastring or byte[]required

Data to encode: a string or a byte array (byte[]), for example from textEncode.

A string is converted to UTF-8 bytes first. A plain JavaScript array of numbers is NOT treated as bytes — [1, 2, 3] is encoded as the text "1,2,3". With several arguments, each one is encoded separately.

Returns

Base64 encoded string.

Example

Normal JavaScript, running in the browser or on the Docly™ server.
let bytes = docly.textEncode("Hello", "utf8");   // byte[]
write(docly.base64(bytes));                      // SGVsbG8=

write(docly.base64("Hello"));                    // SGVsbG8= — strings are encoded as UTF-8