When I built a UAE end-of-service gratuity calculator, I did what most developers do first: I looked at the existing calculators and copied the shape of their logic. That was a mistake — because most of them implement a law that stopped existing in February 2022.
Here is the correct model, the edge cases that matter, and how I encoded it.
The legal model (Article 51, Federal Decree-Law 33/2021)
Gratuity for a full-time foreign employee in the UAE mainland private sector:
- Based on the last basic salary only — housing, transport and every other allowance are excluded.
- Daily wage = monthly basic ÷ 30.
- First five years: 21 days of basic wage per year.
- Every year after the fifth: 30 days per year.
- A part-year after the first year counts pro-rata.
- Cap: the total cannot exceed 24 monthly basic salaries (two years' wage).
- Below one year of service, statutory gratuity is zero.
gratuity = min( basic/30 × 21 × min(years,5) + basic/30 × 30 × max(years-5,0), 24 × basic ) The 2022 change most calculators still get wrong
Before 2 February 2022 the UAE had "limited" and "unlimited" contracts, and resigning under a limited contract could cut your gratuity to one-third or two-thirds. Decree-Law 33/2021 abolished that system. Today all private-sector contracts are fixed-term, and resigning does not reduce gratuity at all.
So if a calculator asks you for a contract type, or applies a resignation penalty, it is calculating a repealed law. In code terms: there is no contractType field and no resignationFactor. Deleting those two inputs was the single most valuable change in the whole project.
Two test cases I use
Case 1 — basic AED 8,000, 4 years.
Daily wage = 266.67. All four years are in the first band: 266.67 × 21 × 4 = AED 22,400. Cap check: 24 × 8,000 = 192,000 — not reached.
Sanity trap: run the same formula on a full package of AED 14,000 (basic + allowances) and you get AED 39,200 — wrong input, wrong answer. The UI has to make "basic salary, as printed on your payslip" unmissable.
Case 2 — basic AED 15,000, 9 years, resigns.
First five years: 500 × 21 × 5 = 52,500. Remaining four: 500 × 30 × 4 = 60,000. Total AED 112,500 — identical whether the employer ends the contract or the employee resigns. Under the pre-2022 rules this is exactly the case that used to lose a third of its value.
The exceptions you must not silently ignore
- DIFC and ADGM run their own regimes (workplace savings schemes such as DEWS) instead of Article 51 gratuity.
- Domestic workers are under a separate law; UAE nationals are in the pension system.
- Some employers have moved staff to the voluntary alternative savings scheme — those employees follow the scheme, not the formula.
- Article 53: the employer must pay end-of-service entitlements within 14 days of the contract ending.
A responsible calculator says these things on the page instead of pretending one formula covers everyone.
The working calculator
The finished tool, plus the full guide with sources, lives here:
- Calculator: https://loonaautomation.github.io/loona-salary-calculators/uae-gratuity-calculator/
- Guide (canonical version of this article): https://loonaautomation.github.io/loona-salary-calculators/guides/how-uae-gratuity-is-calculated.html
No sign-up, and all inputs stay in the browser. If you maintain anything similar — payroll tools, HR templates, expat guides — it is worth ten minutes to check whether your logic still contains a contract-type question. If it does, your users are being under-quoted by a law that no longer exists.
