Microdosimetric energy depositions have been suggested as a key variable for the modeling of the relative biological effectiveness (RBE) in proton and ion radiation therapy. However, microdosimetry has been underutilized in radiation therapy. Recent advances in detector technology allow the design of new mico- and nano-dosimeters. At the same time Monte Carlo (MC) simulations have become more widely used in radiation therapy. In order to address the growing interest in the field, a microdosimetric extension was developed in TOPAS. The extension provides users with the functionality to simulate microdosimetric spectra as well as the contribution of secondary particles to the spectra, calculate microdosimetric parameters, and determine RBE with a biological weighting function approach or with the microdosimetric kinetic (MK) model. Simulations were conducted with the extension and the results were compared with published experimental data and other simulation results for three types of microdosimeters, a spherical tissue equivalent proportional counter (TEPC), a cylindrical TEPC and a solid state microdosimeter. The corresponding microdosimetric spectra obtained with TOPAS from the plateau region to the distal tail of the Bragg curve generally show good agreement with the published data.