SimpleByteConversionDocumentation

Convert Primitive Types to and from Bytes

Supported Types and Nodes

Basic types provide two-way ToBytes and FromBytes conversion:

TypeTo bytesRestore from bytes
int32IntToBytesBytesToInt
int64Int64ToBytesBytesToInt64
floatFloatToBytesBytesToFloat
doubleDoubleToBytesBytesToDouble
boolBoolToBytesBytesToBool
FStringStringToBytesBytesToString

All nodes are BlueprintPure and can be used directly as pure Blueprint functions without execution pins.

Use these nodes for custom protocols, lightweight storage, and binary communication. The C++ snippet below illustrates how the conversion works.

Blueprint Conversion Example

The first graph prints numbers, a Boolean, and a string after converting each value to bytes and back with its matching node.

Test

The second graph converts a vector, a color, and a constraint struct to bytes and back, then reads a component or field.

Test

The third graph prints byte array lengths and JSON text for structs. The two outputs serve different purposes.

Test

Memory Layout, Byte Order, and UTF-8

This C++ example shows how to convert a primitive value:

// 以 int32 为例,直接内存拷贝
void ByteConverter::IntToBytes(int32 Value, TArray<uint8>& OutBytes)
{
OutBytes.SetNumUninitialized(sizeof(int32));
FMemory::Memcpy(OutBytes.GetData(), &Value, sizeof(int32));
}

The example uses FMemory::Memcpy to copy a primitive value’s memory representation. String conversion uses UTF-8 and handles the null terminator for use across platforms.

UTF-8 defines the text encoding. Both endpoints still need to agree on the length, whether it includes the terminator and how to represent empty strings. The receiver cannot assume that an arbitrary byte array contains a readable terminator. The int32 example uses the host’s representation and specifies no byte order for cross-platform use.