Snippy trims layers and comps to their content in time, so you can remove spare timeline space without adjusting every in and out point by hand. It is a free micro tool in Motion Dock.

Select layers in an open composition, then choose what should set their timing. To keys fits each layer to its animation. In point and Out point use the playhead.

Work area and Markers use timing you have already marked. Extend restores room at a layer's end.

See the timing before you click

Hover an action to see its proposed span. The faint bar shows the previous span. Hovering leaves the composition unchanged.

With no usable selection, the bar shows an example. It is a timing diagram, not a view of the composition's pixels.

Fit the composition or time the words

Fit comp sets the composition’s duration from all its layers. Read time sets text layer lengths from their word counts and can arrange them end to end.

Snippy works on timeline timing. It does not detect transparent edges or crop the composition’s width and height. For a first result, trim a layer to two keyframes.