I would like to convert a bytes type to a string type.

How can this be done in pure CameLIGO?:

let data: bytes = [%bytes "hello"] in
let str: string = ???

Thank you, Edward

1 Answer 1


If you are using literal bytes i don't think you can do it from the standard lib of Ligo. You need to build your bytes to string function.

If you are using bytes create from a Michelson string you can do:

let data: string = "hello" in
let data: bytes = Bytes.pack data in
let str: string = Option.unopt((Bytes.unpack data) : string option)
  • 1
    Thanks very much for posting! Nov 30, 2022 at 19:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.