A balun design algorithm based on the compensation matching capacitors and the active S parameter is given in this paper. Compared with the inductor matching network, the compensation matching capacitors not only compensate the phase and the amplitude error of the balun, but also occupy a compact chip area. Considering the coupling between two differential terminals of the balun, the active S parameter is adopted. On the basis of the active S parameter, the reflection coefficients of two differential terminals are calculated directly. On the basis of this algorithm, the simulated phase error and the amplitude error of the balun are less than 0.97°and 0.13 dB, from 15 to 18 GHz. Moreover, a 5-bit differential switch-type phase shifter with two baluns is designed in the 180-nm complementary metal oxide semiconductor (CMOS) process at Ku band. Thanks to the small phase error of two baluns, the tested RMS phase error is less than 4°, from 15 to 18 GHz.