Endotracheal tube (ET) misplacement is common in pediatric patients, which can lead to the serious complication. It would be helpful if there is an easy-to-use tool to predict the optimal ET depth considering in each patient’s characteristics. Therefore, we plan to develop a novel machine learning (ML) model to predict the appropriate ET depth in pediatric patients. This study retrospectively collected data from 1436 pediatric patients aged < 7 years who underwent chest x-ray examination in an intubated state. Patient data including age, sex, height weight, the internal diameter (ID) of the ET, and ET depth were collected from electronic medical records and chest x-ray. Among these, 1436 data were divided into training (70%, n = 1007) and testing (30%, n = 429) datasets. The training dataset was used to build the appropriate ET depth estimation model, while the test dataset was used to compare the model performance with the formula-based methods such as age-based method, height-based method and tube-ID method. The rate of inappropriate ET location was significantly lower in our ML model (17.9%) compared to formula-based methods (35.7%, 62.2%, and 46.6%). The relative risk [95% confidence interval, CI] of an inappropriate ET location compared to ML model in the age-based, height-based, and tube ID-based method were 1.99 [1.56–2.52], 3.47 [2.80–4.30], and 2.60 [2.07–3.26], respectively. In addition, compared to ML model, the relative risk of shallow intubation tended to be higher in the age-based method, whereas the risk of the deep or endobronchial intubation tended to be higher in the height-based and the tube ID-based method. The use of our ML model was able to predict optimal ET depth for pediatric patients only with basic patient information and reduce the risk of inappropriate ET placement. It will be helpful to clinicians unfamiliar with pediatric tracheal intubation to determine the appropriate ET depth.