Binary.FromText
BinaryDecodes text encoded as Base64 or hexadecimal into a binary value.
Syntax
Binary.FromText(text as nullable text, optional encoding as nullable number) as nullable binaryParameters
| Name | Type | Required | Description |
|---|---|---|---|
text | text | Yes | The Base64 or hex-encoded text to decode. |
encoding | number | No | The binary encoding format: BinaryEncoding.Base64 (default) or BinaryEncoding.Hex. |
Return Value
binary — The binary value decoded from the text.
Remarks
Binary.FromText decodes a text string that represents binary data in Base64 or hexadecimal format. The encoding parameter determines which format to expect:
- BinaryEncoding.Base64 (default) — standard Base64 encoding (e.g., "SGVsbG8=").
- BinaryEncoding.Hex — hexadecimal encoding (e.g., "48656C6C6F").
This is commonly used when APIs return binary data encoded as Base64 strings (e.g., image data, file attachments).
Examples
Example 1: Decode Base64 text
let
Base64Text = "SGVsbG8gV29ybGQ=",
Decoded = Binary.FromText(Base64Text, BinaryEncoding.Base64),
AsText = Text.FromBinary(Decoded)
in
#table({"Encoded", "Decoded"}, {{Base64Text, AsText}})Result
Encoded | Decoded | |
|---|---|---|
| 1 | SGVsbG8gV29ybGQ= | Hello World |
Example 2: Decode hexadecimal text
let
HexText = "48656C6C6F",
Decoded = Binary.FromText(HexText, BinaryEncoding.Hex),
AsText = Text.FromBinary(Decoded)
in
#table({"Hex", "Decoded"}, {{HexText, AsText}})Result
Hex | Decoded | |
|---|---|---|
| 1 | 48656C6C6F | Hello |
Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks