Abstract The miniaturization and stability of electronic devices are becoming increasingly important today. We attempt to provide the theoretical support for designing spintronic devices by numerically investigating spin transport in finite size quantum spin Hall insulators (QSHI) under a perpendicular weak magnetic field. By modifying magnetic field strength, we find the gapped spin up and spin down bands are split to realize a half-metal phase which is a promising candidate for designing an efficient spin filter. Moreover, one of the two energy gaps becomes larger and the other smaller due to the weakened or enhanced coupling between two edge states. Here we propose and demonstrate the spin filter based on a finite size QSHI junction under a magnetic field and the polarity can be inverted by a bias voltage or magnetic field. Interestingly, we find a bipolar spin diode effect that only one spin channel is opened and the other spin channel is closed at positive bias, and the opposite spin electron can be transmitted with negative bias. Two spin filters in series can be a spin transistor, the on and off states can be controlled by spin polarization of one spin filter. We show that the topological spin transistor can be controlled by the gate voltage, and it survives in moderate disorder.