--- title: "Converting string to/from Base64" slug: "converting-string-tofrom-base64" updated: 2023-01-06T15:50:01Z published: 2023-01-06T15:50:00Z canonical: "docs.catchpoint.com/converting-string-tofrom-base64" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.catchpoint.com/llms.txt > Use this file to discover all available pages before exploring further. # Converting string to/from Base64 ## Overview The sub-macro `base64to()` converts a string to base64. This can be used within an `extract` macro as a third parameter, or within a `var` macro. The sub-macro `base64from()` is used to decode a base64 string. This can be used with `extract` macro as well as with `var` macro. ## Examples ### **syntax: base64to()** **Example**: ``` var val = 123456789; var valToBase64 = ${var(val, base64to())}; var data = ${extract("resp-content", "regexp:(.*)", "base64to()")} ``` ### **syntax: base64from()** **Example**: ``` var val = 123456789; var valToBase64 = ${var(val, base64to())}; var valFromBase64 = ${var(valToBase64, base64from())}; var data = ${extract("resp-content", "regexp:(.*)\", "base64from()")} ``` Below is a sample transaction, which encodes a string to base64 and then back. ``` // Step - 1 open("http://www.example.com/") waitForNoRequest(5000) var val = 123456789; var valToBase64 = ${var(val, base64to())}; var valFromBase64 = ${var(valToBase64, base64from())}; typeKeys(//textarea[@id='paste_code'], "val=${var(val)}, valToBase64=${var(valToBase64)}, valFromBase64=${var(valFromBase64)}") assert("${var(val, eq(${var(valFromBase64)}))}") ``` ```