A p-n junction, an interface between two regions of a material populated with carriers of opposite charge, is a basic building block of solid state electronic devices. From the fundamental physics perspective, it often serves as a tool to reveal the unconventional transport behavior of novel materials. In this work, we show that a p-n junction made from a three dimensional topological insulator (3DTI) in a magnetic field realizes an electronic Mach-Zehnder interferometer with virtually perfect visibility. This is owed to the confinement of the topological Dirac fermion state to a closed two-dimensional surface, which offers the unprecedented possibility of utilizing external fields to design networks of chiral modes wrapping around the bulk in closed trajectories, without the need of complex constrictions or etching. Remarkably, this junction also acts as a spin filter, where the path of the particle is tied to the direction of spin propagation. It therefore constitutes a novel and highly tunable spintronic device where spin polarized input and output currents are naturally formed and could be accessed and manipulated seperately.