The invention relates to a three-dimensional printer having a support material forming function. The three-dimensional printer comprises a printing head component, a printing platform and a controller, the printing head component can independently move relative to the printing platform in the three-dimensional directions; the controller is electrically connected with the printing head component and the printing platform; the printing head component comprises a fusion chamber, after being fused in the fusion chamber, a print material is deposited layer by layer on the printing platform according to the preset procedures; a first power unit is loaded with a foaming agent, and the first power unit supplies the foaming agent to the fusion chamber, so that the foaming agent is mixed and fused with the print material. When a support part is printed, the foaming agent is added into the fusion chamber, the volume of the print material expands after the foaming agent and the print material are mixed and fused, the expanded fused material is deposited layer by layer on the printing platform to form the support part, the density of the support part is correspondingly reduced, and the weight of a used support material is correspondingly reduced, so that the purpose of lowering the cost is achieved.