An optimal power flow algorithm for unbalanced three-phase distribution grids is pre-sented in this paper as a new tool for grid planning on low voltage level. As additional equipmentlike electric vehicles, heat pumps or solar power systems can sometimes cause unbalanced powerflows, existing algorithms have to be adapted. In comparison to algorithms considering balancedpower flows, the presented algorithm uses a complete model of a three-phase four-wire low voltagegrid. Additionally, a constraint for the voltage unbalance in the grid is introduced. The algorithm canbe used to optimize the operation of energy storage systems in unbalanced systems. The used gridmodel, constraints, objective function and solver are explained in detail. A validation of the algorithmusing a commercial tool is done. Additionally, three exemplary optimizations are performed to showpossible applications for this tool.