We present here a method for cleaning intermediate-size (up to 50 nm) contamination from highly oriented pyrolytic graphite and graphene. Electron-beam-induced deposition of carbonaceous material on graphene and graphite surfaces inside a scanning electron microscope, which is difficult to remove by conventional techniques, can be removed by direct mechanical wiping using a graphite nanoeraser, thus drastically reducing the amount of contamination. We discuss potential applications of this cleaning procedure.