A small home-made device has exploded in a toilet in the rest room of a fast-food outlet in western Sydney, police say.

The device was detonated in the men's toilet cubicle at a McDonald's restaurant on High Street in Penrith about 9.10pm yesterday.

"The explosion damaged the toilet cistern and an air vent," NSW Police said in a statement today.

"There was nobody in the rest room at the time.