A work machine comprising: an articulated front work device configured by coupling, in a mutually rotatable manner, a plurality of driven members (8, 9, 10) including a work tool provided at a tip end; a plurality of hydraulic actuators (5, 6, 7) that respectively drive the plurality of driven members on a basis of an operation signal; an operation device (23a, 23b) that outputs the operation signal to, of the plurality of hydraulic actuators, a hydraulic actuator (5, 5, 7) desired by an operator; a posture sensor (30, 31, 32) that detects respective postures of the plurality of driven members of the front work device; and a controller that performs area limiting control of outputting the operation signal to at least one hydraulic actuator of the plurality of hydraulic actuators or correcting the operation signal, such that the front work device moves on a target surface set for an object of work by the front work device or an area on an upper side of the target surface, characterized in that wherein the work machine further includes a grounding state sensor that detects a grounding state of the work tool on soil, the controller is configured to output or correct the operation signal such that a relative angle of the work tool with respect to the target surface is maintained if a distance between the work tool and the target surface is equal to or less than a preset first threshold value when it is determined, on a basis of a result of detection by the grounding state sensor, that the work tool is grounded on the soil, and, the controller is configured to output or correct the operation signal such that the relative angle of the work tool with respect to the target surface is maintained if the distance between the work tool and the target surface is equal to or less than a preset second threshold value set smaller than the first threshold value when it is determined, on the basis of the result of detection by the grounding state sensor, that the work tool is not grounded on the soil. an articulated front work device configured by coupling, in a mutually rotatable manner, a plurality of driven members (8, 9, 10) including a work tool provided at a tip end; a plurality of hydraulic actuators (5, 6, 7) that respectively drive the plurality of driven members on a basis of an operation signal; an operation device (23a, 23b) that outputs the operation signal to, of the plurality of hydraulic actuators, a hydraulic actuator (5, 5, 7) desired by an operator; a posture sensor (30, 31, 32) that detects respective postures of the plurality of driven members of the front work device; and a controller that performs area limiting control of outputting the operation signal to at least one hydraulic actuator of the plurality of hydraulic actuators or correcting the operation signal, such that the front work device moves on a target surface set for an object of work by the front work device or an area on an upper side of the target surface, characterized in that wherein the work machine further includes a grounding state sensor that detects a grounding state of the work tool on soil, the controller is configured to output or correct the operation signal such that a relative angle of the work tool with respect to the target surface is maintained if a distance between the work tool and the target surface is equal to or less than a preset first threshold value when it is determined, on a basis of a result of detection by the grounding state sensor, that the work tool is grounded on the soil, and, the controller is configured to output or correct the operation signal such that the relative angle of the work tool with respect to the target surface is maintained if the distance between the work tool and the target surface is equal to or less than a preset second threshold value set smaller than the first threshold value when it is determined, on the basis of the result of detection by the grounding state sensor, that the work tool is not grounded on the soil.