download Pins & Boxes
https://aescripts.com/pins-and-boxes/

Pins and Boxes is an automatic layout system for Adobe After Effects.
In this tutorial you learn how to use the new Anchor Controls of Pins & Boxes 1.1. Anchor controls allow you to position the anchor point of a text layer relative to its content – so no matter how the text changes, the anchor always stays at the bottom of the text, for example. This gives you a very accurate control over the dynamic layout. If the anchor point is at the bottom, for example, the text “grows upwards” if more lines are added to the text or the font size is increased. And if the anchor is in the center, the text stays perfectly centered, no matter how many lines it has.
Do your boxes sometimes move a tiny bit left or right, depending on what the last or first letter of the text is? Also this problem can be solved with proper anchor placement, as described in this tutorial.
Anchor control is most useful for text layers, but also works with other layer types.