A portfolio is a combination of two or more securities as investment targets for a certain period of time with certain conditions. The Markowitz method is a method that emphasizes efforts to maximize return expectations and can minimize stock risk. One method that can be used to measure risk is Expected Shortfall (ES). ES is an expected measure of risk whose value is above Value-at-Risk (VaR). To make it easier to calculate optimal portfolios with the Markowitz method and risk analysis with ES, an application was made using the Matlab GUI. The data used in this study consisted of three JII stocks including CPIN, CTRA, and BSDE stocks. The results of the portfolio formation with the Markowitz method obtained an optimal portfolio, namely the combination of CPIN = 34.7% and BSDE = 65.3% stocks. At the 95% confidence level, the ES value of 0.206727 is greater than the VaR value (0.15512).