Fiber lasers are widely used in industrial processing, sensing, medical and communications applications due to their simple structure, good stability and low cost. With the rapid development of fiber lasers and the sustained improvement of industrial laser quality requirements, researchers in ultrafast optics focus on how to get laser pulses with high output power and narrow pulse duration. Q-switched technology is one of the most effective techniques to generate ultrashort pulses. In this paper, a tungsten diselenide saturable absorber with 16.82% modulation depth is prepared by chemical vapor deposition. Experimental results show that when the pump power changes from 115.7 mW to 630 mW, the all-fiber laser can achieve a stable Q-switched pulse output. The repetition rate of the output pulse varies from 80.32 kHz to 204.2 kHz, the pulse duration is 581 ns, the maximum output power is 17.1 mW and the maximum pulse energy is 83.7 nJ. Results in this paper show that tungsten diselenide can be applied to ultrafast optics, which is a kind of saturable absorption material with excellent properties.