When we create flows in Power Automate, it’s common to receive text that isn’t perfectly formatted, with extra spaces, unwanted characters, or parts of a string you don’t need. Cleaning the text before saving it to SharePoint, sending an email, or creating a file is essential.
In this tutorial, I will tell you how to remove characters from a string in Power Automate. Here I will cover:
- Power Automate trim characters from a string to remove unwanted spaces or tabs.
- Remove Characters with the Replace Function in Power Automate.
- Strip out unwanted symbols with Power Automate and remove special characters.
- Remove the first character in a string using Power Automate substring expressions.
- Power Automate removes the last character for precise text formatting.
- Remove the first and last characters together with a smart Power Automate substring trick.
- Cut off extra text using Power Automate, remove the last N characters.
- Remove multiple characters from a string in Power Automate.
Power Automate Trim Character From String
Before we dig deeper into the remove functions of Power Automate, let’s learn another important and mainly used trim function, how to trim characters from a string in Power Automate.
trim() function of Power Automate returns the string value without the leading and trailing whitespace.
Suppose you are collecting attendee details through a Microsoft Form named Event Registrations.

Some people accidentally add extra spaces before or after their names, for example:
" Jon Patel "
Before saving these names into a SharePoint list, you need to clean them up so that they show “Jon Patel” without extra spaces.
Follow the steps below to Trim Characters in Power Automate:
- Go to Power Automate. Click on Create > Automated cloud flow. Name: Trim Character From String. Select trigger: When a new response is submitted. Select your Microsoft Form from the dropdown.

- To retrieve the response, add the Get response details action from the Microsoft Forms connector. Then, select the Form ID from the dropdown menu and choose the Response ID from the dynamic content of the ‘When a new response is submitted’ trigger.

- Add a compose action and provide the following expression:
trim(outputs('Get_response_details')?['Name'])

- Add a Create item action for your SharePoint list (or wherever you store registrations). In the Attendee Name column, insert the above compose action output.

Save the flow and submit a new Event Registration with leading and trailing spaces in the name.

After the flow runs successfully, check the SharePoint list: the saved name will appear clean, with no extra spaces.

This ensures that every attendee name from the Event Registrations form is automatically cleaned up before it’s saved or used elsewhere in Power Automate.
Remove Multiple Characters From a String in Power Automate
You receive daily sales data in a string like Order#1234-Completed, but for reporting, you only need the order number. You can use Power Automate’s Replace function to remove the text Order# and -Completed, leaving only 1234.
To do this, follow the steps below:
- Go to Power Automate and click Create -> Instant Cloud Flow. Select Manually trigger a flow as the trigger.
- Next, add an Initialize Variable action and provide the parameters below:
- Name: varData
- Type: String
- Value:
Order#1234-Completed

- Add a Compose Action to Remove Prefix using the following expression:
replace(variables('varData'),'Order#','')

- Add another Compose action (or extend the previous one) to remove -Completed:
replace(outputs('Compose'),'-Completed','')

Click Save, then Test -> Manually -> Run flow. Check the last Compose action’s output. It should display:

Tip: If you need to remove multiple different substrings at once, you can nest replace() functions:
replace(
replace(variables('varOrder'),'Order#',''),
'-Completed',''
)
Remove Special Characters From a String In Power Automate
You receive customer feedback through an email form, and some comments include special characters such as @, #, $, or %.
Before saving these comments to a SharePoint list, you want to remove all special characters and keep only letters, numbers, and spaces.
Follow the steps below:
- Go to Power Automate -> Click Create -> Instant cloud flow -> choose Manually trigger a flow -> Create.
- In the trigger, click + Add an input -> select Text. Name it Feedback.

- Add a Compose Action with a Replace Expression in Inputs, enter the following expression:
replace(replace(replace(replace(replace(replace(replace(replace(replace(
triggerBody()?['text'],'!',''),'@',''),'#',''),'$',''),'%',''),'^',''),
'&',''),'*',''),'(','')

Click Save -> Test -> Manually. Enter a sample comment, for example:

Run the flow and check the output of the Compose action.

For common cases, you can chain multiple replace() functions to remove only specific unwanted characters.
Remove the first character in a string using Power Automate substring expressions
Your company generates Order IDs in the format #12345, where the first character (#) is reserved for internal systems. Before sending the Order ID to a customer’s email, you need to remove the # and keep just 12345.
- Go to Power Automate -> Click Create -> Instant cloud flow -> choose Manually trigger a flow -> Create.
- In the trigger, click + Add an input -> select Text. Name it OrderID.
- Add a Compose action in the Inputs box of the Compose action, enter:
substring(triggerBody()?['text'], 1, sub(length(triggerBody()?['text']),1))
Where:
- triggerBody()?[‘text’]: the original string from the manual input.
- 1: start at index 1 (second character, because indexes start at 0).
- sub(length(…),1): take the length of the string minus 1 character.

Click Save -> Test -> Manually. Enter a sample Order ID such as #12345.

After the flow runs successfully, check the output of the Compose action.

Power Automate Remove the Last Character From String
In this section, we will learn how to remove the last character from a string using Power Automate.
Suppose you receive customer codes from an external system in the format ABC123-, where the trailing dash (-) is unnecessary. Before saving these codes to a SharePoint list, you need to remove the last character.
- Create an Instant cloud flow -> choose Manually trigger a flow.
- Add an Initialize variable action and provide the following parameters to store that customer code:
- Name: varCode
- Type: String
- Value: ABC123-

- Add a compose action and provide the following expression:
substring(variables('varCode'), 0, sub(length(variables('varCode')),1))

Output:

Remove the First and Last Characters Together From String In Power Automate
Suppose your marketing team receives social media hashtags, such as *Launch2025*, from a third-party app. Before posting these as clean titles in a Teams message, you need to strip the leading and trailing asterisks, leaving only Launch2025.
Follow the steps below:
- Create an Instant cloud flow -> choose Manually trigger a flow.
- Add an Initialize variable action and provide the following parameters to store that customer code:
- Name: varTag
- Type: String
- Value: *Launch2025*
- Add a compose action and provide the following expression:
substring(triggerBody()?['text'],1,sub(length(triggerBody()?['text']),2))
This starts from index 1 (skips the first character) and takes the total length minus 2 (skips thelast character).

Save the flow, run a manual test.

Remove the Last N Characters in Power Automate
Suppose your HR team stores employee ID codes in a SharePoint list in the format EMP45212025, where the last four digits represent the year.
Before generating a report, you need to remove the last 4 characters so the output shows only the core employee code EMP4521.
To do this follow the below steps:
- Create an Instant cloud flow -> choose Manually trigger a flow.
- In the trigger, click + Add an input -> Text. Name it EmployeeID.
- Add a compose action and provide the following expression:

Save the flow, run a manual test, and enter a value such as EMP45212025.

Click Run Flow. Once the flow runs successfully, click on the Compose action to check the output.

In this Power Autoamte tutorial, we explored many methods to remove or trim characters from strings:
- Trim: remove leading and trailing spaces.
- Replace: delete specific words, symbols, or substrings.
- Substring: precisely cut the first, last, or last N characters.
- Nested Replace: strip multiple different characters in a single expression.
By combining these functions, we can handle everything from simple whitespace cleanup to complex text-formatting needs in Power Automate.
You may also like the following tutorials:
- Set No Selected Item in a Power Apps Gallery
- Create SharePoint Term in Term Store Using Power Automate
- Create Indexed Columns in SharePoint Using Power Automate
- Retrieve SharePoint List Items by Created Date Range Using REST API
- Add a New Attendee to a Meeting Without Email Others Using Power Automate

Hey! I’m Bijay Kumar, founder of SPGuides.com and a Microsoft Business Applications MVP (Power Automate, Power Apps). I launched this site in 2020 because I truly enjoy working with SharePoint, Power Platform, and SharePoint Framework (SPFx), and wanted to share that passion through step-by-step tutorials, guides, and training videos. My mission is to help you learn these technologies so you can utilize SharePoint, enhance productivity, and potentially build business solutions along the way.