This paper describes how to optimize energy storage devices (ESDs) by maximizing their net present value (NPV). This requires both technical and economic information. The relevant technical information is specified in concise form by the energy-power relation (Ragone-plot) of the ESD and its lifetime. The economic information is given in terms of operation costs (energy costs), investment costs, and the economic benefit created by operating the ESD. The NPV is expressed as a function of variables such as the size of the ESD. An appropriate choice of these variables maximizes the NPV. If the benefit is given in terms of the energy supplied by the ESD and the lifetime is operation independent, the optimization reduces to a minimization of the total lifecycle costs. In this case a knowledge of the economic benefit, which is often the quantity that is most difficult to model, is not required. In more general cases, e.g. if the lifetime depends on optimization variables, a quantification of the benefit is necessary in order to maximize the NPV. We illustrate the approach with various stationary and mobile applications, and for batteries and capacitors.