Power Automate: convert HTML to text
Add the Html to text action from the Content Conversion connector, put the HTML in its Content field, and use the plain text it returns. Microsoft's connector page points to string functions in expressions for any clean-up afterward.
How does the Html to text action work?
The action converts an HTML document to plain text. Its one required input is Content, the HTML document to convert, and it returns the plain text content as a string. Microsoft lists the connector as Standard class in Power Automate, and the connector page is marked Preview.
What does the output look like?
| In the HTML | In the text |
|---|---|
| A link such as <a href='link'>text</a> | text[link]; only text if both are the same |
| Headers (h1, h2 and so on) and th cells | Uppercased |
| An unordered list | Lines that start with * |
| Empty lines | Trimmed |
| A line longer than 80 characters | A line break follows after 80 |
What are the limits?
- Maximum content length is 5 MB.
- Maximum depth of the HTML DOM tree is 70.
- Links that use href='#...' are ignored.
- New lines in the input HTML collapse into spaces, so runs of them can leave a blank space between them.
Why are the line breaks or links wrong?
Microsoft says unexpected line breaks, wrong formatting or missing hyperlinks are by design, because the connector does not keep the HTML formatting and removes hyperlinks. Its suggested workaround is to use string functions in expressions to replace content. Examples are in replacing text with replace() and trimming spaces from text.
Is there an expression instead?
Microsoft documents the Html to text action for this job, and its full function reference for expressions lists no function that strips HTML. To go the other way and build HTML, see formatting a Create HTML table.
FAQ
Does Html to text keep my links?
Not as clickable links. Microsoft's connector page says a link becomes its text followed by the address in square brackets.
Why is my text cut into short lines?
Microsoft says the maximum line length is 80 characters, after which a line break follows.
Is the Html to text action a premium connector?
Microsoft lists the Content Conversion connector as Standard class in Power Automate.
Sources
- Content Conversion connector (Microsoft Learn)
- Workflow expressions and functions reference (Microsoft Learn)