Binary.ToText
BinaryEncodes binary data as Base64 or hexadecimal text.
Syntax
Binary.ToText(binary as nullable binary, optional encoding as nullable number) as nullable textParameters
| Name | Type | Required | Description |
|---|---|---|---|
binary | binary | Yes | The binary value to encode as text. |
encoding | number | No | The encoding format: BinaryEncoding.Base64 (default) or BinaryEncoding.Hex. |
Return Value
text — The text representation of the binary value.
Remarks
Binary.ToText converts a binary value into a text string using either Base64 or hexadecimal encoding. This is the inverse of Binary.FromText.
- BinaryEncoding.Base64 (default) — produces a standard Base64 string.
- BinaryEncoding.Hex — produces a hexadecimal string (uppercase).
Common use cases include encoding file content for embedding in JSON payloads or generating checksums for display.
Examples
Example 1: Encode text as Base64
let
Original = "Power Query",
AsBinary = Binary.From(Original),
Base64 = Binary.ToText(AsBinary, BinaryEncoding.Base64)
in
#table({"Original", "Base64"}, {{Original, Base64}})Result
Original | Base64 | |
|---|---|---|
| 1 | Power Query | UG93ZXIgUXVlcnk= |
Example 2: Encode text as hexadecimal
let
Original = "Hello",
AsBinary = Binary.From(Original),
Hex = Binary.ToText(AsBinary, BinaryEncoding.Hex)
in
#table({"Original", "Hex"}, {{Original, Hex}})Result
Original | Hex | |
|---|---|---|
| 1 | Hello | 48656C6C6F |
Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks