We prove the following stability version of the edge isoperimetric inequality for the cube: any subset of the cube with average boundary degree within K of the minimum possible is ε-close to a union of L disjoint cubes, where L≤L(K,ε) is independent of the dimension. This extends a stability result of Ellis, and can viewed as a dimension-free version of Friedgut's junta theorem.