We investigate the pressure-dependent mechanical behaviour of the zeolitic imidazolate framework ZIF-4 (M(im)2; M2+ = Co2+ or Zn2+, im- = imidazolate) with high pressure, synchrotron powder X-ray diffraction and mercury intrusion measurements. A displacive phase transition from a highly compressible open pore (op) phase with continuous porosity (space group Pbca, bulk modulus ∼1.4 GPa) to a closed pore (cp) phase with inaccessible porosity (space group P21/c, bulk modulus ∼3.3-4.9 GPa) is triggered by the application of mechanical pressure. Over the course of the transitions, both ZIF-4 materials contract by about 20% in volume. However, the threshold pressure, the reversibility and the immediate repeatability of the phase transition depend on the metal cation. ZIF-4(Zn) undergoes the op-cp phase transition at a hydrostatic mechanical pressure of only 28 MPa, while ZIF-4(Co) requires about 50 MPa to initiate the transition. Interestingly, ZIF-4(Co) fully returns to the op phase after decompression, whereas ZIF-4(Zn) remains in the cp phase after pressure release and requires subsequent heating to switch back to the op phase. These variations in high pressure behaviour can be rationalised on the basis of the different electron configurations of the respective M2+ ions (3d10 for Zn2+ and 3d7 for Co2+). Our results present the first examples of op-cp phase transitions (i.e. breathing transitions) of ZIFs driven by mechanical pressure and suggest potential applications of these functional materials as shock absorbers, nanodampers, or in mechanocalorics.