We propose the concept of 'topological Hamiltonian' for topological insulators and superconductors in interacting systems. The eigenvalues of the topological Hamiltonian are significantly different from the physical energy spectra, but we show that the topological Hamiltonian contains the information of gapless surface states, therefore it is an exact tool for topological invariants.