Each gram of protein and carbohydrate has about 4 calories and each gram of fat has about 9. Your calories are split by the percentages you choose, then divided by those values: protein grams = calories × protein% ÷ 4, carb grams = calories × carb% ÷ 4, fat grams = calories × fat% ÷ 9. The three percentages should add up to 100.
Example: 2,200 calories at 30/40/30 gives 165 g protein (660 kcal), 220 g carbs (880 kcal) and 73 g fat (660 kcal).
A common range for active people is 0.7 to 1 gram per pound of body weight (1.6 to 2.2 g per kg). Check the protein grams here against your weight and adjust the split.
Use the TDEE calculator to estimate maintenance calories, then subtract about 500 to lose weight or add 250 to gain slowly.
The best split is one you can stick to. Total calories drive weight change; the split mostly affects hunger, training performance and preference.
See also: TDEE calculator · BMR calculator · BMI calculator