Download the Get Rect preset and drag the Get Rect.ffx file to:
Documents ➡ Adobe ➡ After Effects 2022* ➡ User Presets
* or your current version
Inside After Effects, navigate to the Effects & Presets window. You should be able to find the preset by searching "get rect". If not, open the dropdown menu and select “Refresh List.”
Within a composition, but with no layer selected, apply the Get Rect preset. This will create a shape layer.
Parent the newly created shape layer to a text layer.
When using Get Rect Pro, do not parent the shape layer. Instead set the source layers under the Get Rect Pro effect settings. Get Rect Pro allows up to 4 sources at once, however you can go beyond this limit by daisy-chaining multiple Get Rect Pro layers.
If you are getting any errors after this step, make sure your expression engine is set to JavaScript (File > Project Settings > Expressions)
With the shape layer selected, navigate to the Effect Controls. Under the Get Rect effect, you can customize how the rectangle will be generated.
Auto X - When toggled on, the rectangle will conform to the width of the text layer. When toggled off, the width of the rectangle will be set to the value of X Margin.
Auto Y - When toggled on, the rectangle will conform to the approximate height of the text layer, based on the font size and leading size, while ignoring ascenders and descenders. When toggled off, the height of the rectangle will be set to the value of Y Margin.
X Margin – Sets the left and right sides of the rectangle in relation to the width of the text layer.
Y Margin – Sets the top and bottom sides of the rectangle in relation to the height of the text layer.
Offset – Nudges the rectangle along the X and Y axis, while keeping it conformed to the text layer.
With the size of your rectangle set, you can customize the rectangle freely (i.e. change fill color, add a stroke, add rounded corners, etc)