A biomimetic hierarchical membrane consisting of ZIF-8 and MXene with controllable morphology could be fabricated by the facile electrochemical deposition method, well-realizing Li+/Mg2+ sieving. This membrane could work stably in real brine with perm-selectivity of Li+/Mg2+ up to 47.4.