After a fight, add up the XP value of every monster the party defeated — each monster’s XP is fixed by its Challenge Rating. That total is split evenly among all the characters who took part, so a 1,000-XP fight shared by five players gives each character 200 XP.
Characters level up when their personal XP total crosses the threshold for the next level. You need 300 total XP for level 2, 900 for level 3, and 2,700 for level 4 — the amounts grow quickly at higher levels (see the table).
Many groups skip XP entirely and use milestone leveling, where the DM levels the party up at story beats instead of tracking points. Both are official: XP rewards careful bookkeeping, while milestones keep the party evenly leveled and cut prep time.