Hex to Bytes
Decodes a hexadecimal string into a raw byte array
Overview
Decodes a hexadecimal string into a raw byte array (Uint8Array). The parser automatically strips an optional leading 0x or 0X prefix as well as common byte separators (spaces, colons :, hyphens -, and newlines) before validating and decoding each pair of hex digits.
An empty string (after stripping prefixes/separators) decodes to a 0-byte Uint8Array. If the cleaned string has an odd number of hex digits or contains any character outside 0-9a-fA-F, execution halts with INVALID_HEX_STRING.
When to Use
- Converting hex-encoded keys, ciphertexts, or test vectors coming from a Prompt Input, Bytes to String, or Script node into raw
Bytes. - Cleaning and decoding colon- or space-delimited hex dumps pasted from external tools like OpenSSL or Wireshark.
Parameter Configuration
This node has no configurable static parameters in the property inspector; its runtime behavior is determined entirely by its algorithm specification and connected ports.
Port I/O Specification
See Ports & Connections for general wiring rules, data type colors, and dynamic port creation.
Input Ports
Port Nature: Fixed Input Ports (1 total).
| Port Name | Port ID | Data Type | Required | Visibility Condition | Description |
|---|---|---|---|---|---|
Hex In |
string |
String |
Required | Always visible | Hexadecimal string to decode (supports optional 0x prefix and space/colon/hyphen delimiters). |
Output Ports
Port Nature: Fixed Output Ports (1 total).
| Port Name | Port ID | Data Type | Visibility Condition | Description |
|---|---|---|---|---|
Bytes Out |
bytes |
Bytes |
Always visible | Decoded raw byte array (Uint8Array). |
Error Cases
When any of the following conditions occurs at runtime, this node transitions to an ERROR state and downstream nodes connected to its outputs do not execute.
| Error Code | Default Engine Message | Trigger Condition |
|---|---|---|
INVALID_HEX_LENGTH |
Hex string length is not even | Raised when the hexadecimal string (excluding whitespace and 0x prefix) has an odd number of digits. |
INVALID_HEX_CHAR |
Hex string contains an invalid character | Raised when the hexadecimal string contains characters outside 0-9, a-f, and A-F. |
Examples
Decoding a Colon-Separated Hex Key String
Convert "00:01:02:03" into a 4-byte Uint8Array.
- Feed the string
"00:01:02:03"into theHex Stringinput port. - The
Bytesoutput port emits the 4-byte array[0x00, 0x01, 0x02, 0x03].