Live training: next batches coming soon. Join the waitlist:Waitlists open:Developer Training →Developer →Copilot Studio Training →Copilot Studio →

How to Convert String to Object in Power Automate

Do you want to convert string to object format in Power Automate? In this Power Automate tutorial, we will see how to convert a string to an object in Power Automate.

While working with Power Automate, you have the json string data, and you want to convert it into json objects. So, you can use those data in your flow in Power Automate.

To convert json string to json object, we can use JSON(). The JSON() will take the value as a string and convert it into a Json object.

Syntax

JSON(<string>)

Here, we will cover the topics below:

  • How to convert string to object in Power Automate.
  • How to convert string to object in Power Automate dynamically

Convert string to object in Power Automate

Here, we will see how to convert a string to an object in Power Automate.

Example 1: Convert string to object in Power Automate

Let’s say we have a string ‘GradyArchie – gradyA@email.com, and you need to convert it into json format, i.e. { “name”: “GradyArchie”, “email”: “gradyA@email.com”}. For this, follow the below steps to achieve it.

1. Open Power Automate Cloud, then click on +Create -> select Instant Cloud Flow.

power automate convert string to json

Then, provide a flow name and select the “Manually trigger a flow” action. Then click on Create.

 convert string to json in power automate

Now, you can see a Manual trigger a flow action is added to the flow page.

Power Automate convert string to object

2. We will initialize a string variable; for this, click on +New step -> select Initialize variable action. Then provide the information below:

  • Name: Provide the name of the variable
  • Type: Provide the type as a string
  • Value: Provide the value like below
Microsoft Power Automate convert string to object

3. We will split the string into two parts; for this, click on Add an action -> select Compose action. Then provide the below information:

  • Inputs: Provide the below expression:
split(variables('varStr'), '-')
 convert string to object Microsoft Power Automate

4. Now, we will convert the string to an object in Power Automate. For this, click on +New step -> select Compose action. Then provide the below information:

Inputs: Provide the below expression:

{
"Topic": "@{outputs('Compose')[0]}",
"Content":"@{outputs('Compose')[1]}"
}
convert string to object in Microsoft Power Automate

5. Then click on save and run the flow manually; you can see the string is converted to an object in Power Automate.

How to convert string to object in Microsoft Power Automate

Example 2: Convert JSON string to object in Power Automate

Let’s say you have json string i.e., ‘{ “name”: “GradyArchie”, “email”: “gradyA@email.com”},’ and we will convert it into json objects { “name”: “GradyArchie”, “email”: “gradyA@email.com”}, for this follow the below steps:

1. Open Power Automate Cloud, then click on +Create -> select Instant Cloud Flow.