Overfull \hboxes can be highlighted/marked in the output document by enabling draft=true or overfullrule=true in the \documentclass settings.
Furthermore, slightly overfull or underfull horizontal boxes can often be somewhat reduced by using the microtype package (since draft mode disables microtyping, the final option has to be specified for the microtype package).
A detailed overview on draft mode can be found here, microtype is elaborated here.
However, is there a way to highlight/mark underfull boxes in the output document?
\showoutputand look in the log, you can not access the information from within tex – David Carlisle Apr 01 '23 at 21:24draftoption for themicrotypepackage no longer exists, so you do not have to load the package with thefinaloption (which doesn't exist anymore, either). – Robert Apr 03 '23 at 22:54