BackgroundPrevious studies have found that obesity is closely related to gastrointestinal cancer (GIC), but there is insufficient evidence to compare the relationship between various obesity indexes and triglyceride glucose index with GIC. MethodsThis study analyzed the relationship between Body mass index (BMI), lipid accumulation product (LAP), Triglyceride glucose (TyG), Triglyceride glucose-body mass index (TyG-BMI), Triglyceride glucose-waist circumference (TyG-Waist), Triglyceride Waist-to-Height Ratio (TyG-WHtR), Visceral adiposity index (VAI), Waist circumference (Waist), Waist-to-Height Ratio (WHtR), and Weight-adjusted waist index (WWI) and GIC. The data from National Health and Nutrition Examination Survey from 1999 to 2018 was utilized. We conducted weighted multiple logistic regression to analyze the relationship between GIC and obesity indexes and subgroup analysis was carried out for further study. After that, survival analysis and restricted cubic spline (RCS)was used to analyze the relationship between various obesity indexes and the prognosis of GIC. ResultsLogistic regression showed that TyG [Q4 vs Q1: OR (95 %CI) = 2.082(1.016 ∼ 4.269)] and LAP [Q4 vs Q1: OR (95 %CI) = 2.046(1.010 ∼ 4.145)] were related to GIC. Survival analysis and RCS found BMI [Q4 vs Q1: HR (95 %CI) = 0.369(0.176 ∼ 0.773)], Waist [Q4 vs Q1: HR (95 %CI) = 0.381(0.193 ∼ 0.753)], and WWI [Q4 vs Q1: HR (95 %CI) = 0.403(0.188 ∼ 0.864)] were significantly related to the prognosis of GIC. ConclusionThere is a complex relationship between obesity and TyG with GIC. Certain indexes may be utilized to assist patients in developing suitable prevention and lifestyle strategies.