An interface in computer science is a mechanism for specifying a contract between different software components, without specifying the implementation details. It defines a set of methods and properties that a class implementing the interface must provide, but does not specify how those methods should be implemented. This allows for flexibility and reusability of code, as well as the ability to use different implementations of the same interface in different situations.