You can build a useful Sri Lankan salary simulator with Python and Streamlit, but there is an important distinction: the code below estimates annual income tax from the Inland Revenue Department’s 2025/2026 tax chart and converts that estimate to a monthly equivalent. It does not reproduce an employer’s APIT withholding from the IRD tables, so its result is not an exact payroll deduction or guaranteed take-home pay.
The prototype is a starting point for modelling regular salary income. It shows the assumptions alongside the estimate and keeps any other deductions separate. To calculate actual APIT, replace the annual-tax approximation with the verified table and rules for the employee’s situation.
As an Amazon Associate I earn from qualifying purchases.
What the simulator calculates—and what it does not
Advance Personal Income Tax (APIT) is tax withheld from employment income when remuneration is paid. Under Section 83A, employers deduct it using tables specified by the Commissioner General of Inland Revenue, then remit the deductions by the 15th of the following month. See the IRD’s APIT guidance.
The example app instead calculates an annual tax estimate from the IRD’s 2025/2026 individual rates, subtracts LKR 1,800,000 of personal relief when the user says they qualify, and divides the result by 12 to show a monthly equivalent. That division is a modelling shortcut; it is not a claim that it matches an APIT table deduction in any particular month.
#1 Best Overall
The IRD’s APIT publications distinguish regular monthly employment income from cases such as secondary employment, lump sums, terminal benefits, non-resident non-citizens, cumulative gains and foreign-employer income. A tool should claim to cover one of those cases only after its matching table and rules have been implemented and checked.
Which tax rules should the prototype use?
The IRD tax chart for Year of Assessment 2025/2026, last updated 2025-08-28, gives personal relief of LKR 1,800,000 for residents and non-resident citizens of Sri Lanka. It applies the following marginal rates to taxable income, not directly to gross salary:
| Taxable-income slice | Rate |
|---|---|
| First LKR 1,000,000 | 6% |
| Next LKR 500,000 | 18% |
| Next LKR 500,000 | 24% |
| Next LKR 500,000 | 30% |
| Balance | 36% |
These bands are encoded in the function below. The example treats annual gross salary as the income being modelled and applies the relief only when selected. It does not account for other income, exemptions, adjustments or special circumstances. Confirm a person’s taxable income and relief eligibility under the applicable rules before relying on the estimate.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Build the Streamlit prototype
1. Install the packages
Use a Python environment for the project, then install Streamlit:
Rank #2
python -m pip install streamlit
2. Save the app
Create a file named app.py. This version accepts monthly gross salary, annualizes it for the tax-chart estimate, and lets the reader enter other monthly deductions separately. Its result labels make clear that the monthly tax figure is only an annualized estimate.
import streamlit as st
RELIEF_LKR = 1_800_000
def annual_tax_estimate(taxable_income: float) -> float:
"""Estimate annual tax using the IRD Y/A 2025/2026 marginal bands."""
remaining = max(0.0, taxable_income)
tax = 0.0
bands = [
(1_000_000, 0.06),
(500_000, 0.18),
(500_000, 0.24),
(500_000, 0.30),
]
for band_width, rate in bands:
slice_amount = min(remaining, band_width)
tax += slice_amount * rate
remaining -= slice_amount
if remaining <= 0:
return tax
# The balance above the listed fixed-width bands is taxed at 36%.
return tax + remaining * 0.36
st.set_page_config(page_title="Sri Lanka Salary Simulator", page_icon="💼")
st.title("Sri Lanka salary and tax estimate")
st.caption("Annual-tax estimate based on the IRD Y/A 2025/2026 chart; not an APIT-table calculation.")
st.subheader("Your pay assumptions")
monthly_gross = st.number_input(
"Regular monthly gross salary (LKR)", min_value=0, value=200_000, step=10_000
)
relief_eligible = st.checkbox(
"Assume I qualify for LKR 1,800,000 personal relief", value=True
)
other_deductions = st.number_input(
"Other monthly deductions to subtract (LKR)", min_value=0, value=0, step=1_000,
help="Enter only deductions you want shown in this estimate. This app does not determine their legal or payroll treatment."
)
annual_gross = monthly_gross * 12
relief = RELIEF_LKR if relief_eligible else 0
estimated_taxable_income = max(0, annual_gross - relief)
annual_tax = annual_tax_estimate(estimated_taxable_income)
monthly_tax_equivalent = annual_tax / 12
estimated_monthly_remainder = max(
0, monthly_gross - monthly_tax_equivalent - other_deductions
)
st.subheader("Estimate")
col1, col2 = st.columns(2)
col1.metric("Annual taxable income used", f"LKR {estimated_taxable_income:,.0f}")
col2.metric("Estimated annual tax", f"LKR {annual_tax:,.0f}")
col1.metric("Annual tax divided by 12", f"LKR {monthly_tax_equivalent:,.0f}")
col2.metric("Remainder after entered deductions", f"LKR {estimated_monthly_remainder:,.0f}")
st.warning(
"The monthly tax figure is annual estimated tax divided by 12, not verified APIT "
"withholding. This estimate does not model every tax rule or payroll deduction. "
"Check the applicable IRD APIT table and your employer's calculation."
)
st.caption("Tax-chart basis: Inland Revenue Department, Year of Assessment 2025/2026.")
3. Run it locally
-
In a terminal opened in the folder containing
app.py, runstreamlit run app.py. -
Open the local address Streamlit prints in the terminal. Enter regular monthly gross salary, indicate whether the relief assumption applies, and enter any other monthly deductions you want the display to subtract.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
Check the displayed annual taxable income and annual tax estimate before interpreting the monthly figures. The app presents the latter as annual tax divided by 12, not as an APIT-table result.
How the calculation works
Annualize the regular monthly salary
The prototype multiplies monthly gross pay by 12. This is an explicit assumption that the same regular salary is paid for all 12 months. It is unsuitable without modification for irregular earnings, bonuses, one-off payments or partial-year employment.
Apply the relief assumption and marginal bands
The function first subtracts relief from annual gross salary, floors taxable income at zero, then taxes each slice at its corresponding rate. Only the income in a slice receives that slice’s rate; for example, crossing into the 18% band does not make the first band taxable at 18%.
Keep deductions distinct
The separate “other monthly deductions” input changes only the displayed remainder. It does not alter taxable income or estimated tax. The cited IRD materials establish the APIT component, not a complete net-pay formula covering employee-side EPF or every employer-specific deduction. Treat the displayed remainder as a scenario estimate, not an authoritative payslip figure.
What to change for genuine APIT withholding
The IRD’s APIT tables page publishes table sets, and the Y/A 2025/2026 APIT guideline identifies its applicability for that assessment year and onwards. To move from an annual chart estimate to a payroll withholding calculator:
-
Choose and label the supported case, such as regular monthly primary employment, and implement the relevant official table rather than substituting annual tax divided by 12.
-
Make the assessment year and table version visible beside every result. Tax tables can change; the sources here do not establish which exact tables or rate changes apply for Y/A 2026/2027.
-
Add other employment cases only when their corresponding table and rules are encoded. Do not reuse the regular monthly path for secondary employment, lump sums, terminal benefits, foreign-employer income or other categories by assumption.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
Keep APIT, EPF and any other deductions as separate line items. Document the source and treatment for each item before labelling a final figure “take-home pay.”
-
Test boundary values around every table threshold and relief condition against the official table or guideline. Record the expected result and the table version used so future changes can be reviewed.
How to present the result responsibly
Put the currency, pay period, assessment year, employment case and calculation basis in the interface—not only in an about page. For the example above, “LKR” and “monthly gross salary” are explicit; the caption identifies Y/A 2025/2026 and warns that the estimate is not APIT-table withholding. If you later implement a table-based route, replace that wording with the specific table and case it supports.
A community forum search result describes a Streamlit project using a salary/APIT framing, but its page was unavailable for verification. That does not establish the code’s tax accuracy, current library usage, security, testing or deployment. Treat the implementation here as an independent educational prototype, not a claim about that project.
Free tools Windows power users keep installed
One-click scans. No signup required.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




