Motivated by entropic optimal transport, time reversal of diffusion processes is revisited. An integration by parts formula is derived for the carre du champ of a Markov process in an abstract space. It leads to a time reversal formula for a wide class of diffusion processes in $ mathbb{R}^n$ possibly with singular drifts, extending the already known results in this domain. The proof of the integration by parts formula relies on stochastic derivatives. Then, this formula is applied to compute the semimartingale characteristics of the time-reversed $P^*$ of a diffusion measure $P$ provided that the relative entropy of $P$ with respect to another diffusion measure $R$ is finite, and the semimartingale characteristics of the time-reversed $R^*$ are known (for instance when the reference path measure $R$ is reversible). As an illustration of the robustness of this method, the integration by parts formula is also employed to derive a time-reversal formula for a random walk on a graph.