How to remove all richtext tags from text without using Text.ContentText (or how to get size of text while ignoring richtext tags)

Is there an official method to convert a piece of RichText (such as <b>Shop</b>) into normal text (i.e. Shop)?

There doesn’t appear to be any having a skim through TextService.

If that method doesn’t exist, is there a method to calculate the size of some text while ignoring all RichText tags?

Both GetTextBoundsParams(...) and :GetTextSize(...) fail to do this. I also want to achieve this without generating a TextLabel and using its ContentText.


print(game.TextService:GetTextSize("<b>Shop<b>", 20, Enum.Font.Arial,, 20)).X)

→ 112

print(game.TextService:GetTextSize("Shop", 20, Enum.Font.Arial,, 20)).X)```

→ 57


print(game.TextService:GetTextSize("<b>Shop<b>", 20, Enum.Font.Arial,, 20)).X)

→ 57

print(game.TextService:GetTextSize("Shop", 20, Enum.Font.Arial,, 20)).X)

→ 57


There is no official method unfortunately.

Someone made a feature request for it though.

There is no specific method, but there is a workaround I found from the same topic linked above:

Create a dummy TextLabel that mimics a TextLabel that is used for the rich text. Then set its text and parent it to the player’s GUI in an off-screen location, and grab the TextBounds property.

1 Like