Ab initio molecular dynamics (AIMD) simulations are carried out to probe the high-pressure behavior of ZIF-8 over wide pressure-range. Under compression, the enormous distortions in the ZnN4 tetrahedral units lead to a crystal-to-amorphous phase transition at around 3 GPa. During the amorphization process, the Zn-N coordination is retained. No other phase change but a possible fracture of the system is proposed above 10 GPa. Depending on released pressures, amorphous states with different densities are recovered. Yet when the applied pressure is released just before the amorphization, the rotations of imidazolate linkers (swing effect) cause an isostructural crystal-to-crystal phase transition, in agreement with experiments. In the tensile regime, no phase transition is perceived up to -2.75 GPa at which point the structural failure is observed. The crystal-amorphous phase transitions are also discovered at around 4 GPa under uniaxial compressions. The amorphous structures formed under uniaxial stress are about 20% denser than the one formed under the hydrostatic pressure. The average Young's modulus and Poisson's ratio of ZIF-8 are estimated to be around 5.6 GPa and 0.4, respectively. Interestingly, the tensile strength of ZIF-8 is found to be about 50% greater than its compressive strength. This paper shows that the experimentally observed phase transitions can be successfully reproduced with a clear explanation about the transition mechanism(s) at the atomistic level and all mechanical properties can be accurately calculated for a given ZIF structure by using AIMD simulations.