How to Convert String to GUID in Power Automate?

While working on an Employee Survey Application, I encountered an interesting challenge. One of the steps in Power Automate required converting a string value, such as an employee’s unique identifier from a form response, into a GUID. If you’ve ever faced a similar requirement in Power Automate, don’t worry—converting a string to a GUID is easy.

In this Power Automate tutorial, I will show you how to convert a string into a GUID format with dashes (with or without curly braces) in Power Automate. I will also explain how to generate a GUID in Power Automate.

Convert String to GUID in Power Automate

When you need to convert a string into a GUID format in Power Automate, you must format the string with specific patterns: groups of characters separated by dashes, optionally enclosed in curly braces. Since Power Automate doesn’t have a built-in function to create a GUID from a given string, we use the substring() and concat() functions to manually format the string into the standard GUID pattern.

Now follow the below steps:

1. Create an Instant Cloud Flow by selecting the ‘Manually trigger a flow’ trigger action.

power automate convert string to guid

2. Add the ‘Initialize Variable‘ action, provide a name, set the type to ‘String,’ and enter the string value you want to convert into a GUID format.

1234567890abcdef1234567890abcdef
Power Automate Convert a String to GUID

3. Add a Compose action to convert the string into a GUID format. Provide the below expressions:

  • Without curly braces:
concat(
    substring(variables('varGUID'), 0, 8), '-', 
    substring(variables('varGUID'), 8, 4), '-', 
    substring(variables('varGUID'), 12, 4), '-', 
    substring(variables('varGUID'), 16, 4), '-', 
    substring(variables('varGUID'), 20, 12)
)
How to convert string to GUID in power automate
  • With curly braces:
concat(
    '{',
    concat(
        substring(variables('varGUID'), 0, 8), '-', 
        substring(variables('varGUID'), 8, 4), '-', 
        substring(variables('varGUID'), 12, 4), '-', 
        substring(variables('varGUID'), 16, 4), '-', 
        substring(variables('varGUID'), 20, 12)
    ),
    '}'
)
Why isn't there a simple Action to convert a String to GUID

Now Save and manually run the flow and check the Compose action outputs.

  • Without curly braces:
Convert GUID to String Using Power Automate
  • With curly braces:
How To Convert String To GUID In Power Automate flow

Get a GUID in Power Automate

Power Automate provides a built-in function, guid(), to generate unique GUIDs dynamically.

ExpressionDescriptionExample Result
guid()Generates a standard GUID.12345678-90ab-cdef-1234-567890abcdef
guid(‘N’)GUID in number format (no hyphens).1234567890abcdef1234567890abcdef
guid(‘B’)GUID with curly braces.{12345678-90ab-cdef-1234-567890abcdef}
guid(‘P’)GUID is enclosed in parentheses.(12345678-90ab-cdef-1234-567890abcdef)

Now, let’s see how to do in Power Automate:

1. Select the ‘Manually trigger a flow’ trigger action, then create a Compose action and provide the below expression:

guid()
How to Get a GUID in Power Automate

Save and manually run the flow. Check the outputs of the Compose action.

Get a GUID in Power Automate

In the same way, you can check the rest of the expression.

Conclusion

This tutorial covered how to work with GUIDs in Power Automate. We learned how to convert a string into a GUID format using the substring() and concat() functions, both with and without curly braces. Additionally, we covered how to generate a GUID dynamically using the built-in guid() function.

You may also like:

>

Build a High-Performance Project Management Site in SharePoint Online

User registration Power Apps canvas app

DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App

Power Platform Tutorial FREE PDF Download

FREE Power Platform Tutorial PDF

Download 135 Pages FREE PDF on Microsoft Power Platform Tutorial. Learn Now…