import ballerina/io;function main (string[] args) {
    string text = "Sample Text";
    blob content = text.toBlob("UTF-8");
    string str = content.toString("UTF-8");
    io:println(str);
}

Blob Type

Blob is a value type in Ballerina that represents a sequence of bytes.

import ballerina/io;
function main (string[] args) {
    string text = "Sample Text";
    blob content = text.toBlob("UTF-8");

Convert the value type string to blob by providing the encoding.

    string str = content.toString("UTF-8");
    io:println(str);
}

Convert the value type blob to string by providing the encoding.

$ ballerina run blob-type.bal
Sample Text