Described is a needle safety device (2, 102) comprising a needle hub (2.2, 102.2), a needle (2.3, 102.3) coupled to the needle hub (2.2, 102.2) and having a distal tip (2.3.1, 102.3.1), an outer needle shield (2.1, 102.1) telescopically coupled to the needle hub (2.2, 102.2), and an inner needle shield (2.4, 102.4) telescopically coupled to the outer needle shield (2.1). The needle safety device (2, 102.2) has a first state in which the distal tip (2.3.1, 102.3.1) is covered by the inner needle shield (2.4, 102.4) and the inner needle shield (2.4, 102.4) is movable in a proximal direction relative to the outer needle shield (2.1, 102.1), a second state in which the distal tip (2.3.1, 102.3.1) is exposed from the inner needle shield (2.4, 102.4), and a third state in which the distal tip (2.3.1, 102.3.1) is covered by the inner needle shield (2.4, 102.4) and the inner needle shield (2.4, 102.4) is immovable in the proximal direction relative to the outer needle shield (2.1, 102.1). The needle safety device (2, 102) includes a first locking mechanism (L1, L101) engaging the inner needle shield (2.4, 102.4) to the outer needle shield (2.1, 102.1) in the first state. The needle hub (2.2, 102.2) includes a release element (2.2.1.1, 102.2.2.2) adapted to release the first locking mechanism (L1, L101) in the second state.