If you want to completely erase the program on the micro:bit, for example, to clear a large number of micro:bits ready for another lesson or workshop, you can flash an erase hex file (.zip attached to this article) to the micro:bit.

This is a minimal hex file with no program data on it. It will clear the program on the processor, so none of the micro:bit sensors or LEDs are being used.

Further  Information

For advanced users, there is an automation mode that can be enabled to perform a variety of functions including erasing the device.

Keywords for search: clear, memory, empty, reset, wipe, automation, factory reset