A terahertz band temperature and magnetic field sensor based on a magneto-fluid-filled D-type microstructure grating is designed. The high sensitivity measurement of temperature and magnetic field is realized by optimizing the structure. The highest temperature sensitivity is 233.88 pm/°C, and the highest magnetic field sensitivity is up to 214.802 pm/mT. When the overall structure size of the sensor was changed by ±0.1 %, the maximal absolute deviation of temperature or magnetic field sensor are 0.018 pm/℃ and 0.03 pm/Oe. At the same time, the dual-parameter demodulation matrix is used to effectively overcome the crosstalk problem.