function calculateDTI() {
// Get inputs
var income = parseFloat(document.getElementById('dti_income').value);
var housing = parseFloat(document.getElementById('dti_housing').value);
var auto = parseFloat(document.getElementById('dti_auto').value);
var student = parseFloat(document.getElementById('dti_student').value);
var cards = parseFloat(document.getElementById('dti_cards').value);
var other = parseFloat(document.getElementById('dti_other').value);
// Handle NaN inputs (treat as 0)
if (isNaN(housing)) housing = 0;
if (isNaN(auto)) auto = 0;
if (isNaN(student)) student = 0;
if (isNaN(cards)) cards = 0;
if (isNaN(other)) other = 0;
// Validation: Income is required
if (isNaN(income) || income <= 0) {
alert("Please enter a valid Gross Monthly Income.");
return;
}
// Calculations
var totalMonthlyDebt = housing + auto + student + cards + other;
var frontEndRatio = (housing / income) * 100;
var backEndRatio = (totalMonthlyDebt / income) * 100;
var disposable = income – totalMonthlyDebt;
// Display Logic
document.getElementById('dti_result_box').style.display = 'block';
// Format Numbers
document.getElementById('dti_final_percent').innerText = backEndRatio.toFixed(2) + '%';
document.getElementById('dti_housing_percent').innerText = frontEndRatio.toFixed(2) + '%';
document.getElementById('dti_total_debt').innerText = '$' + totalMonthlyDebt.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
document.getElementById('dti_disposable').innerText = '$' + disposable.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
// Determine Status and Badge
var badge = document.getElementById('dti_status_badge');
var recText = document.getElementById('dti_recommendation');
// Reset classes
badge.className = 'dti-badge';
if (backEndRatio <= 36) {
badge.classList.add('dti-good');
badge.innerText = 'Excellent';
recText.innerText = "Your DTI is in the ideal range. Lenders view this ratio very favorably.";
} else if (backEndRatio <= 43) {
badge.classList.add('dti-warn');
badge.innerText = 'Good / Average';
recText.innerText = "Your DTI is manageable but approaching the limit for Qualified Mortgages (43%). Avoid taking on new debt.";
} else if (backEndRatio <= 50) {
badge.classList.add('dti-bad');
badge.innerText = 'High Risk';
recText.innerText = "Lenders may hesitate to approve loans. Consider reducing debt or increasing income before applying for a mortgage.";
} else {
badge.classList.add('dti-bad');
badge.innerText = 'Critical';
recText.innerText = "Your debt load is very high relative to your income. Financial restructuring is highly recommended.";
}
}
Understanding Your Debt-to-Income (DTI) Ratio
The Debt-to-Income (DTI) ratio is one of the most critical metrics lenders use to assess your ability to repay a loan. Unlike your credit score, which measures your history of paying debts, the DTI measures your current capacity to manage monthly payments relative to your gross income.
Front-End vs. Back-End Ratio
When calculating DTI, there are actually two numbers that financial institutions look at:
Front-End Ratio: This strictly looks at your housing costs (rent or mortgage, property taxes, insurance, and HOA fees) divided by your gross monthly income. Ideally, this should be under 28%.
Back-End Ratio: This is the "Total DTI" calculated by our tool above. It includes housing costs plus all other recurring debt payments like car loans, student loans, and credit card minimums. This gives a complete picture of your financial obligations.
Why the 43% Benchmark Matters
In the mortgage industry, 43% is widely considered the maximum DTI ratio a borrower can have and still get a Qualified Mortgage. While some lenders (such as for FHA or VA loans) may accept higher ratios with compensating factors (like large cash reserves), keeping your DTI below 43%—and ideally below 36%—significantly increases your chances of approval and secures better interest rates.
How to Improve Your DTI Ratio
If your calculation shows a "High Risk" or "Critical" status, consider these strategies:
Pay Down High-Interest Debt: Aggressively paying off credit cards lowers your monthly minimum obligations, which directly reduces your DTI.
Increase Income: Taking on a side gig or negotiating a raise increases the denominator in the calculation, lowering the percentage.
Refinance Loans: Extending the term of a car loan or student loan can lower the monthly payment, improving your ratio immediately, though it may cost more in interest over the long run.
Use this calculator regularly as you pay down debt to track your progress toward financial health and loan eligibility.