Abstract The objective of this paper is to determine the optimal shape of a body – a two-dimensional elliptical cylinder in this study – located in a compressible inviscid flow governed by the Euler equations, such that the pressure acting on the surface of the body is minimized. The formulation to obtain the optimal shape is based on optimal control theory. The optimal state is defined as the state in which the performance function – the integration of the square sum of the traction on the surface of the body – is minimized due to a reduction in pressure on the body. The compressible Euler equations are treated as constraint equations. That is, the optimal shape of the body is considered to be that shape that minimizes the pressure acting on the body under the constraint of the Euler equations. A gradient of the performance function is computed by using the adjoint variables. The weighted gradient method is used as the minimization algorithm. The volume of the body is assumed to be constant. For the discretization of both the state and adjoint equations, the mixed interpolation method based on the bubble function interpolation presented previously by the authors is employed. Both the structured mesh around the surface and the smoothing procedure are employed for the gradient. As numerical studies, the shape optimization of a body in a uniform flow field is carried out. The initial shape of the body is assumed to be an ellipse. The shape is updated by minimizing the pressure on the surface. Finally, the shape of the body should be almost a flat line. Stable optimal shape determination of a body in a compressible inviscid flow is obtained by using the presented method.