For most devices, this will perform the unroot. Some custom firmware images will automatically re-root the device when booting, rendering this process ineffective. [2] X Research source

Press and hold the Power button to shut off the device. Press and hold Volume Up, Home, and Power to boot into the Recovery menu. Use the Volume buttons to select “wipe data/factory reset” and press the Power button to select it. Select “wipe data partition” and then “reboot system now”. Your Galaxy will reboot and wipe all of the data, returning it to factory settings.