A work machine comprising: a work device having a boom, an arm, and a bucket; an operation device (1c, 1d) for operating the work device; and a controller capable of controlling the work device using an excavation work control for controlling the work device so as to cause a claw tip of the bucket to move along a predetermined target surface and a leveling work control for controlling the work device so as to cause the bucket to move along the target surface while maintaining a posture of the bucket with respect to the target surface, characterized in that the controller is configured to calculate, based on posture data and size data on the work device and position data on the target surface, an arm tip difference that is a distance from a tip of the arm to the target surface, execute the leveling work control in a case of the calculated arm tip difference being equal to or less than a threshold that is a distance from the tip of the arm to a claw tip of the bucket, there being no input of a bucket operation to the operation device (1c, 1d), and there being an input of an arm operation to the operation device (1c, 1d), and execute the excavation work control in a case of the calculated arm tip difference being more than the threshold, or in a case of there being an input of the bucket operation to the operation device (1c, 1d), or in a case of there being no input of the arm operation to the operation device (1c, 1d). a work device having a boom, an arm, and a bucket; an operation device (1c, 1d) for operating the work device; and a controller capable of controlling the work device using an excavation work control for controlling the work device so as to cause a claw tip of the bucket to move along a predetermined target surface and a leveling work control for controlling the work device so as to cause the bucket to move along the target surface while maintaining a posture of the bucket with respect to the target surface, characterized in that the controller is configured to calculate, based on posture data and size data on the work device and position data on the target surface, an arm tip difference that is a distance from a tip of the arm to the target surface, execute the leveling work control in a case of the calculated arm tip difference being equal to or less than a threshold that is a distance from the tip of the arm to a claw tip of the bucket, there being no input of a bucket operation to the operation device (1c, 1d), and there being an input of an arm operation to the operation device (1c, 1d), and execute the excavation work control in a case of the calculated arm tip difference being more than the threshold, or in a case of there being an input of the bucket operation to the operation device (1c, 1d), or in a case of there being no input of the arm operation to the operation device (1c, 1d). calculate, based on posture data and size data on the work device and position data on the target surface, an arm tip difference that is a distance from a tip of the arm to the target surface, execute the leveling work control in a case of the calculated arm tip difference being equal to or less than a threshold that is a distance from the tip of the arm to a claw tip of the bucket, there being no input of a bucket operation to the operation device (1c, 1d), and there being an input of an arm operation to the operation device (1c, 1d), and execute the excavation work control in a case of the calculated arm tip difference being more than the threshold, or in a case of there being an input of the bucket operation to the operation device (1c, 1d), or in a case of there being no input of the arm operation to the operation device (1c, 1d).