The invention provides a distributed type photovoltaic on-grid and off-grid energy storage inversion system, which comprises a photovoltaic array, a BOOST one-way conversion circuit, a maximum power point tracking MPPT device, an energy storage system, a direct current bus, an on-grid and off-grid controller, an on-grid and off-grid inverter and a micro-grid, wherein the output energy of the photovoltaic array sequentially passes through the BOOST one-way conversion circuit and the maximum power point tracking MPPT device and is connected to the direct current bus; the energy storage system isconnected into the direct current bus in parallel, the direct-current bus is connected with the micro-grid through an on-grid and off-grid inverter, and the micro-grid is connected with the main gridto form a grid-connected mode, and the micro-grid is disconnected with the main grid to form an off-grid mode; the on-grid and off-grid controller is connected with the on-grid and off-grid inverter,an on-grid and off-grid controller is used for carrying out island detection on the micro-grid, and automatic switching is carried out on the grid-connected mode and the off-grid mode according to the detection result. Coordination and unification of grid connection, grid disconnection and energy storage are realized, and system cost is reduced.