base64(data) Last updated: 23. Oct 2026
Converts data to base64 encoded string.
See also: Example: Calling external APIs Example: Sending SMS through BulkSMS gateway from Docly JS API
Parameters
| Name | Type | Description |
|---|---|---|
| data | string or byte[] | 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
Code example (JS)
JS is normal JavaScript either 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 Output
The JS code above produces the output shown below:SGVsbG8=SGVsbG8=