web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to Convert Base64 ...
Power Automate
Answered

How to Convert Base64 Code to Text in Power Automate Desktop

(0) ShareShare
ReportReport
Posted on by

This is an example of based64 code that I want to convert: Um9hciAtIEthdHkgUGVycnk

I have the same question (0)
  • Verified answer
    Deenuji_Loganathan_ Profile Picture
    6,255 Moderator on at

    @CodyChrunos 

     

    Method 1: Powershell

    You can leverage powershell code for the conversion

    Flow screenshot:

    Deenuji_3-1717310532213.png

     

    Deenuji_4-1717310596338.png

     

    Powershell code:

     

    $base64String = "%base64String%"
    $bytes = [System.Convert]::FromBase64String($base64String)
    $text = [System.Text.Encoding]::UTF8.GetString($bytes)
    Write-Output $text

     

     

     

    Output:

    Deenuji_5-1717310701039.png

     

     

    Method 2:

    You can leverage .Net code for the same:

    Deenuji_1-1717310192384.png

     

    Deenuji_2-1717310302315.png

     

     


    Thanks,
    Deenuji Loganathan 👩‍💻
    Automation Evangelist 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀

  • CodyChrunos Profile Picture
    on at

    Thank you. Just tried method one with error: 

    Exception calling "FromBase64String" with "1" argument(s): "Invalid length for a Base-64 char array or string."
    At C:\Users\cody\AppData\Local\Temp\Robin\nvvlzsyla5x.tmp.ps1:2 char:1
    + $bytes = [System.Convert]::FromBase64String($base64String)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : FormatException

    Exception calling "GetString" with "1" argument(s): "Array cannot be null.
    Parameter name: bytes"
    At C:\Users\cody\AppData\Local\Temp\Robin\nvvlzsyla5x.tmp.ps1:3 char:1
    + $text = [System.Text.Encoding]::UTF8.GetString($bytes)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ArgumentNullException

  • Deenuji_Loganathan_ Profile Picture
    6,255 Moderator on at

    @CodyChrunos 

     

    Have you created set variable like below for base64string?

    Deenuji_0-1717311271096.jpeg

     

    Please share screenshot of your flow pls?

     

     

  • CodyChrunos Profile Picture
    on at

    Screenshot 2024-06-02 145654.png

  • CodyChrunos Profile Picture
    on at

    I see. You added a "=". Thank you. It worked for me when I added a =

  • Deenuji_Loganathan_ Profile Picture
    6,255 Moderator on at

    @CodyChrunos  _ glad to hear that 🙂


    For future seekers - Please copy and paste the below code into your power automate desktop(keep anyone one method)

     

     

    SET base64String TO $'''Um9hciAtIEthdHkgUGVycnk='''
    @@copilotGeneratedAction: 'False'
    Scripting.RunPowershellScript.RunPowershellScript Script: $'''$base64String = \"%base64String%\"
    $bytes = [System.Convert]::FromBase64String($base64String)
    $text = [System.Text.Encoding]::UTF8.GetString($bytes)
    Write-Output $text''' ScriptOutput=> PowershellOutput
    Scripting.RunDotNetScript Imports: $'''System.Text''' Language: System.DotNetActionLanguageType.CSharp Script: $'''byte[] data = Convert.FromBase64String(base64String);
    base64String = Encoding.UTF8.GetString(data);''' @'name:base64String': base64String @'type:base64String': $'''String''' @'direction:base64String': $'''InOut''' @base64String=> base64String

     

    How to copy/paste above code into power automate desktop?

    Deenuji_0-1717311863753.gif

     

     


    Thanks,
    Deenuji Loganathan 👩‍💻
    Automation Evangelist 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀

     

  • CodyChrunos Profile Picture
    on at

    Sorry to bother you again. When the code is UGxheSBQcmV0ZW5kIC0gQWxleCBTYW1wc29u, it won't work. If somehow I remove the "=", it will work in this case.

  • Deenuji_Loganathan_ Profile Picture
    6,255 Moderator on at

    @CodyChrunos 

     

    Please note: You don't require to add "=" in your base64string.

     

    Please copy and paste the below code into your power automate desktop? - Please refer the below gif how to do that.

     

     

    SET base64String TO $'''UGxheSBQcmV0ZW5kIC0gQWxleCBTYW1wc29u'''
    @@copilotGeneratedAction: 'False'
    Scripting.RunPowershellScript.RunPowershellScript Script: $'''$base64String = \"%base64String%\"
    $bytes = [System.Convert]::FromBase64String($base64String)
    $text = [System.Text.Encoding]::UTF8.GetString($bytes)
    Write-Output $text''' ScriptOutput=> PowershellOutput

     

     

    How to copy/paste the above code into your power automate desktop?

    Deenuji_0-1717314679828.gif

     


    Thanks,
    Deenuji Loganathan 👩‍💻
    Automation Evangelist 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀

  • Deenuji_Loganathan_ Profile Picture
    6,255 Moderator on at

    @CodyChrunos 

     

    The first example which you shared earlier "Um9hciAtIEthdHkgUGVycnk" seems don't have any meaningful text, that's why its not returning anything or throwing error.

     

    Then next one "UGxheSBQcmV0ZW5kIC0gQWxleCBTYW1wc29u" seems have some meaningful text so it returns "Play Pretend - Alex Sampson" as output.

     


    Thanks,
    Deenuji Loganathan 👩‍💻
    Automation Evangelist 🤖
    Follow me on LinkedIn 👥

    -------------------------------------------------------------------------------------------------------------
    If I've helped solve your query, kindly mark my response as the solution ✔ and give it a thumbs up!👍 Your feedback supports future seekers 🚀

     

     

  • CodyChrunos Profile Picture
    on at

    I use a loop to work this around:

    SET base64String TO $'''U2hlJ3MgQ3JhenkgYnV0IFNoZSdzIE1pbmUgLSBBbGV4IFNwYXJyb3c='''
    LOOP LoopIndex FROM 1 TO 4 STEP 1
     @@copilotGeneratedAction: 'False'
    Scripting.RunPowershellScript.RunPowershellScript Script: $'''$base64String = \"%base64String%\"
    $bytes = [System.Convert]::FromBase64String($base64String)
    $text = [System.Text.Encoding]::UTF8.GetString($bytes)
    Write-Output $text''' ScriptOutput=> PowershellOutput
     IF IsEmpty(PowershellOutput) THEN
     SET base64String TO $'''%base64String%='''
     ELSE
     EXIT LOOP
     END
    END
    Text.Trim Text: PowershellOutput TrimOption: Text.TrimOption.Both TrimmedText=> TrimmedText

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 632

#2
Haque Profile Picture

Haque 458

#3
Valantis Profile Picture

Valantis 357

Last 30 days Overall leaderboard