Ultraviolet B light-emitting diodes (UVB LEDs) hold promise in medical and agricultural applications. The commonly used sapphire substrate for their epitaxy growth possesses a high refractive index and excellent UV light absorption characteristics. However, this high refractive index can induce total internal reflection (TIR) within the substrate, leading to decreased Light Extraction Efficiency (LEE) due to light absorption within the material. In this study, UVB LED chips were detached from the sub-mount substrate and directly affixed onto an aluminum nitride (AlN) substrate with superior heat dissipation using a eutectic process. This was undertaken to diminish packaged thermal resistance (PTR). Simultaneously, optimization of the UVB LED packaging structure was employed to alleviate LEE losses caused by the TIR phenomenon, with the overarching goal of enhancin external quantum efficiency (EQE). The final experimental findings suggest that optimal LEE is achieved with packaging dimensions, including a length (ELL) of 2 mm, a width (ELW) of 1.62 mm, and a height (ELH) of 0.52 mm. At an input current of 200 mA, the output power reaches 50 mW, resulting in an EQE of 6.3%. Furthermore, the packaged thermal resistance from the chip to the substrate surface can be reduced to 4.615 K/W.