We calculate the formal degrees of square-integrable unipotent representations of exceptional Chevalley groups over p-adic fields. The representations can be uniquely partitioned into $L$-packets, so as to have the degrees proportional within a packet. The main ingredient is a theorem of Schneider and Stuhler, which gives the degree as a value of an Euler-Poincare function. The latter is expressed in terms of restriction to parahoric subgroups, which we compute using Green polynomials, branching of Weyl group representations, and weight diagrams of modules over affine Hecke algebras. The computer program CHEVIE was involved in the more difficult cases. The latter work was performed by Frank Luebeck, and is described in his appendix to the paper.