A grass trimmer includes an operating device configured for a user to operate and a grass trimmer device including a grass trimmer head and a motor. The grass trimmer head includes a spool configured for a grass trimmer line to wind around and a housing formed with an accommodating cavity. When the grass trimmer is mounted with the grass trimmer line, a part of the grass trimmer line protruding outside the housing is defined as an effective part of the grass trimmer line. The grass trimmer further includes a controller configured to control the grass trimmer head to release a grass trimmer line when the grass trimmer head is mounted with the grass trimmer line and a length of the effective part is detected to be less than or equal to a preset value.