Calculate Rate of Inflation
This calculator helps you determine the rate of inflation between two periods using the Consumer Price Index (CPI) values for those periods. Inflation measures the rate at which the general level of prices for goods and services is rising, and subsequently, purchasing power is falling.
Result:
The inflation rate will be displayed here.
Understanding Inflation and CPI
The Consumer Price Index (CPI) is a measure that examines the weighted average of prices of a basket of consumer goods and services, such as transportation, food, and medical care. It is calculated by taking price changes for each item in the predetermined basket of goods and averaging them. Changes in the CPI are used to measure inflation, which is the rate at which the prices of goods and services increase.
The formula used to calculate the rate of inflation between two periods is:
Inflation Rate = ((CPI in Final Period – CPI in Initial Period) / CPI in Initial Period) * 100
For example, if the CPI was 250.5 in the initial period and rose to 265.2 in the final period, the inflation rate would be:
Inflation Rate = ((265.2 – 250.5) / 250.5) * 100 = (14.7 / 250.5) * 100 ≈ 5.87%
A positive inflation rate indicates that prices have increased, while a negative rate (deflation) indicates that prices have decreased.
.calculator-container {
font-family: sans-serif;
border: 1px solid #ccc;
padding: 20px;
border-radius: 8px;
max-width: 600px;
margin: 20px auto;
background-color: #f9f9f9;
}
.calculator-container h2, .calculator-container h3 {
text-align: center;
color: #333;
}
.calculator-inputs {
margin-top: 20px;
display: flex;
flex-direction: column;
gap: 15px;
}
.input-group {
display: flex;
flex-direction: column;
}
.input-group label {
margin-bottom: 5px;
font-weight: bold;
color: #555;
}
.input-group input {
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 16px;
}
.calculator-inputs button {
padding: 12px 20px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
transition: background-color 0.3s ease;
}
.calculator-inputs button:hover {
background-color: #45a049;
}
.calculator-result {
margin-top: 25px;
padding: 15px;
background-color: #e0f7fa;
border: 1px solid #b2ebf2;
border-radius: 4px;
text-align: center;
}
#result {
font-size: 18px;
font-weight: bold;
color: #00796b;
}
.calculator-explanation {
margin-top: 30px;
padding-top: 20px;
border-top: 1px dashed #ccc;
font-size: 14px;
line-height: 1.6;
color: #666;
}
.calculator-explanation p {
margin-bottom: 15px;
}
.calculator-explanation strong {
color: #444;
}
function calculateInflationRate() {
var cpiInitial = parseFloat(document.getElementById("cpi_initial").value);
var cpiFinal = parseFloat(document.getElementById("cpi_final").value);
var resultDiv = document.getElementById("result");
if (isNaN(cpiInitial) || isNaN(cpiFinal) || cpiInitial <= 0) {
resultDiv.textContent = "Please enter valid positive numbers for CPI values.";
resultDiv.style.color = "red";
return;
}
var inflationRate = ((cpiFinal – cpiInitial) / cpiInitial) * 100;
resultDiv.textContent = inflationRate.toFixed(2) + "%";
resultDiv.style.color = "#00796b"; /* Greenish color for positive results */
if (inflationRate < 0) {
resultDiv.style.color = "#d32f2f"; /* Reddish color for deflation */
}
}