The TUNEL assay detects DNA fragmentation by labeling the terminal end of nucleic acids. This method involves using terminal deoxynucleotidyl transferase (TdT) to add dUTPs that are labeled with a marker to the 3'-OH ends of fragmented DNA. This allows for the visualization of apoptotic cells under a microscope.