The Water Quality Index (WQI) is a comprehensive mathematical tool used to transform complex water quality data into a single, easy-to-understand number. It provides a standardized method for reporting the health of aquatic ecosystems and the safety of water for human use.
This calculator utilizes the NSF (National Sanitation Foundation) weighted method, focusing on six critical parameters that determine the biological and chemical health of a water body.
Water Quality Rating Scale
WQI Range
Quality Rating
Usage Implications
91 – 100
Excellent
Pristine water, supports all aquatic life.
71 – 90
Good
Minor impairment, safe for most uses.
51 – 70
Fair
Moderate pollution, needs treatment for drinking.
26 – 50
Poor
High pollution, toxic to some aquatic life.
0 – 25
Very Poor
Severe pollution, unsafe for most purposes.
Key Parameters Explained
pH Level: Measures how acidic or basic the water is. Most aquatic life thrives between 6.5 and 8.5.
Dissolved Oxygen (DO): Essential for the survival of fish and other aquatic organisms. High levels indicate a healthy, aerobic environment.
Turbidity: Measures water clarity. High turbidity can block sunlight for plants and clog fish gills.
Nitrates: High levels usually come from fertilizer runoff or sewage, leading to excessive algae growth (eutrophication).
TDS (Total Dissolved Solids): The concentration of dissolved inorganic salts and organic matter. High levels can affect water taste and plumbing.
BOD: Measures the amount of oxygen consumed by bacteria while decomposing organic matter. High BOD suggests organic pollution.
Practical Example
Imagine a local river with the following readings: pH 7.5, DO 85%, Turbidity 10 NTU, Nitrates 4.0 mg/L, TDS 300 mg/L, and BOD 2.0 mg/L. Entering these values into the calculator would yield a WQI of approximately 82, categorizing the river as "Good." While healthy, the presence of nitrates and moderate TDS suggests some agricultural runoff is present.
function calculateWQI() {
// Get Input Values
var ph = parseFloat(document.getElementById('ph_val').value);
var doo = parseFloat(document.getElementById('do_val').value);
var turb = parseFloat(document.getElementById('turb_val').value);
var nit = parseFloat(document.getElementById('nit_val').value);
var tds = parseFloat(document.getElementById('tds_val').value);
var bod = parseFloat(document.getElementById('bod_val').value);
// Validate
if (isNaN(ph) || isNaN(doo) || isNaN(turb) || isNaN(nit) || isNaN(tds) || isNaN(bod)) {
alert("Please enter valid numeric values for all parameters.");
return;
}
// Sub-index calculations (Simplified NSF curves)
var q_ph, q_do, q_turb, q_nit, q_tds, q_bod;
// 1. pH Sub-index (Optimal around 7)
if (ph >= 6.5 && ph <= 8.5) q_ph = 100;
else if (ph 11) q_ph = 10;
else q_ph = 100 – (Math.abs(7 – ph) * 20);
// 2. DO Sub-index (Higher is better)
if (doo >= 90) q_do = 100;
else if (doo < 20) q_do = 10;
else q_do = doo;
// 3. Turbidity (Lower is better)
if (turb 100) q_turb = 5;
else q_turb = 100 – (turb * 0.9);
// 4. Nitrates (Lower is better)
if (nit 50) q_nit = 10;
else q_nit = 100 – (nit * 1.8);
// 5. TDS (Lower is better)
if (tds 1000) q_tds = 10;
else q_tds = 100 – (tds * 0.08);
// 6. BOD (Lower is better)
if (bod 30) q_bod = 5;
else q_bod = 100 – (bod * 3);
// NSF Weights (normalized for 6 parameters)
// Relative importance: DO(0.20), pH(0.18), BOD(0.18), Nit(0.15), Turb(0.15), TDS(0.14)
var w_ph = 0.18, w_do = 0.20, w_turb = 0.15, w_nit = 0.15, w_tds = 0.14, w_bod = 0.18;
var finalWQI = (q_ph * w_ph) + (q_do * w_do) + (q_turb * w_turb) + (q_nit * w_nit) + (q_tds * w_tds) + (q_bod * w_bod);
// Safety clamp
finalWQI = Math.min(100, Math.max(0, finalWQI));
// Display results
var resultDiv = document.getElementById('wqi_result_container');
var scoreDisp = document.getElementById('wqi_score_display');
var statusDisp = document.getElementById('wqi_status_display');
resultDiv.style.display = "block";
scoreDisp.innerText = Math.round(finalWQI);
if (finalWQI > 90) {
statusDisp.innerText = "Excellent";
resultDiv.style.backgroundColor = "#d4edda";
resultDiv.style.color = "#155724";
} else if (finalWQI > 70) {
statusDisp.innerText = "Good";
resultDiv.style.backgroundColor = "#e2f3ff";
resultDiv.style.color = "#004085";
} else if (finalWQI > 50) {
statusDisp.innerText = "Fair";
resultDiv.style.backgroundColor = "#fff3cd";
resultDiv.style.color = "#856404";
} else if (finalWQI > 25) {
statusDisp.innerText = "Poor";
resultDiv.style.backgroundColor = "#f8d7da";
resultDiv.style.color = "#721c24";
} else {
statusDisp.innerText = "Very Poor";
resultDiv.style.backgroundColor = "#343a40";
resultDiv.style.color = "#ffffff";
}
// Smooth scroll to result
resultDiv.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
}