How to Replace String in JSON using Power Automate

A few days ago, I worked with a client to develop a Project Management system utilizing SharePoint lists, libraries, and site pages.

The client requires JSON data for each project, and based on the project status, I want to update the Project priority value: replace ‘Low’ with ‘High’ if the status is ‘In Progress’.

In this tutorial, I will explain how to replace a string value in a JSON object using Power Automate, as well as how to replace null values in a JSON Object.

Example 1: Power Automate Replace String in JSON

Suppose I have a JSON Object with one project, as shown below, and I want to replace a string value, i.e., ‘Priority’, from ‘Low‘ to ‘High‘.

{
  "ProjectID": "PRJ-2025-001",
  "ProjectName": "Website Redesign",
  "Client": "Acme Corp",
  "StartDate": "2025-06-01",
  "EndDate": "2025-08-15",
  "Status": "In Progress",
  "Priority": "Low"
}

To do this, I will create an Instant cloud flow in Power Automate that will be triggered by clicking the button.

Check out the steps below:

  1. Sign in to Power Automate, click on + Create, and select Instant cloud flow. Provide the Flow name and choose the trigger flow (i.e., Manually trigger a flow), then click the Create button.
  2. Next, add a “Compose” action and insert the JSON object into the Inputs parameter.
Inputs: {
  "ProjectID": "PRJ-2025-001",
  "ProjectName": "Website Redesign",
  "Client": "Acme Corp",
  "StartDate": "2025-06-01",
  "EndDate": "2025-08-15",
  "Status": "In Progress",
  "Priority": "Low"
}
Power Automate replace text string in json
  1. Then, I will add one more “Compose” action to replace the “Low” string with another string value, “High“.
    • Inputs: Insert the expression given in the code below
json(replace(string(outputs('Compose')), 'Low', 'High'))

First, we need to convert the JSON to a string using the string function. Then, the replace() function is used to remove the specified strings and replace them with another string. Then, it is converted back to JSON format using the JSON expression.
Power Automate Replace a String in JSON
  1. Now, click on the Save icon to save the flow. Then, run the flow.
  2. After the flow runs successfully, open the compose action, and it removes the string value “Low” and produces output like below.
Microsoft Power Automate replace json string

Check out Filter Array in Power Automate Examples

Example 2: Power Automate Replace Special Characters in JSON

I will explain this with another example, ie, replacing special characters in json with blank values.

Let’s say you have a JSON string for Project details that is present in an unusual format, such as \r and escaped quotes.

{
  "ProjectName\r": "Intranet Portal Design\r",
  "Manager": "David Smith",
  "ProjectID\r": "\"PRJ-001789\"\r"
}

In the json mentioned above, I wanted to replace the special character “\r” with a blank value.

As you already know, how to create a Power Automate flow. Do start from the steps below:

  1. Below the trigger, add a “Compose” action that will store the JSON object. Provide your Json in the Inputs parameter of compose.
{
  "ProjectName\r": "Intranet Portal Design\r",
  "Manager": "David Smith",
  "ProjectID\r": "\"PRJ-001789\"\r"
}
Power Automate replace special characters in json
  1. Now, I will take another Compose to provide the expression that will replace the special characters with blank values. See the expression below.
json(replace(replace(string(outputs('Compose_-_Special_Characters')),'\r', ''), '\"', ''))
Power Automate Replace Special characters JSON

Save and run the flow.

  1. Once the flow runs successfully, you can check the output in the Compose action. Have a look at the reference image.
Power Automate replace JSON String Special characters

This way, you can replace the special characters in a JSON by using Power Automate.

Check out Replace Value in an Array in Power Automate

Example 3: Replace Empty String with Null Values in JSON using Power Automate

In this section, I will describe how to replace the empty string values in json with null values using Power Automate.

In the example below, you can see that I have a Project Details in a JSON object, which contains StartDate and EndDate fields with empty string values. Now, we will replace these empty strings with null values.

Power Automate replace null in json

Go through the replace() expression below:

  1. Add a ‘Compose‘ action and set the expression as given in the code below.
Inputs: json(replace(string(outputs('Compose_-_Project_Details')),'""','null'))
Replace with Null Values in JSON Power Automate
  1. Then, save and manually run the Power Automate flow. Once the flow is executed, you can check the result in the compose outputs, where the StartDate and EndDate will be replaced with null values. Have a look at the screenshot below.
Power Automate replace JSON String with null

You can use the replace() function to replace the text strings, characters, or any other text values with new text values using Power Automate.

In this tutorial, I will explain how to replace a String in JSON using Power Automate. You can drop a comment in the comments section if you have any questions or suggestions.

You may like the following tutorials:

>

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…