This paper presents a linear programming approach for the optimal control of nonlinear switched systems where the control is the switching sequence. This is done by introducing modal occupation measures, which allow to relax the problem as a primal linear programming (LP) problem. Its dual linear program of Hamilton-Jacobi-Bellman inequalities is also characterized. The LPs are then solved numerically with a converging hierarchy of primal-dual moment-sum-of-squares (SOS) linear matrix inequalities (LMI). Because of the special structure of switched systems, we obtain a much more efficient method than could be achieved by applying standard moment/SOS LMI hierarchies for general optimal control problems.through an adequate switching strategy, in order to impose global stability and/or performance. Interested readers may refer to the survey papers [17,31,44,33] and the books [32,46] and the references therein.In this context, these systems are generally controlled by intrinsically discontinuous control signals, whose switching rule must be carefully designed to guarantee stability and performance properties. As far as optimality is concerned, several results are available in two main different contexts.The first category of methods exploits necessary optimality conditions, in the form of Pontryagin's maximum principle (the so-called indirect approaches), or through a large nonlinear discretization of the problem (the so-called direct approaches). The first contributions can be found in [8,22,36] where the problem has been formulated and partial solutions provided through generalized Hamilton-Jacobi-Bellman (HJB) equations or inequalities and convex optimization. In [38,47,43], the maximum principle is generalized to the case of general hybrid systems with nonlinear dynamics. The case of switched systems is discussed in [4,42,2]. For general nonlinear problems and hence for switched systems, only local optimality can be guaranteed , even when discretization can be properly controlled [51]. The subject is still largely open and we are far from a complete and numericaly tractable solution to the switched optimal control problem.The second category collects extensions of the performance indices H 2 and H ∞ originally developed for linear time invariant systems without switching, and use the flexibility of Lyapunov's approach, see for instance [20,16] and references therein. Even for linear switched systems, the proposed results are based on nonconvex optimization problems (e.g., bilinear matrix inequality conditions) difficult to solve directly. Sufficient convex Linear Matrix Inequality (LMI) design conditions may be obtained, yielding computed solutions which are suboptimal, but at the price of introducing a conservatism (pessimism) and a gap to optimality which is hard, if not impossible, to evaluate. Since the computation of this optimal strategy is a difficult task, a suboptimal solution is of interest only when it is proved to be consistent, meaning that it imposes to the switched system a performance not worse th...