Price to Earnings (P/E) Ratio Calculator
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #f8f9fa;
color: #333;
line-height: 1.6;
margin: 0;
padding: 20px;
}
.pe-calc-container {
max-width: 700px;
margin: 30px auto;
background-color: #ffffff;
padding: 30px;
border-radius: 8px;
box-shadow: 0 4px 15px rgba(0, 74, 153, 0.1);
border: 1px solid #e0e0e0;
}
h1, h2 {
color: #004a99;
text-align: center;
margin-bottom: 20px;
}
.input-group {
margin-bottom: 15px;
display: flex;
flex-direction: column;
align-items: flex-start;
}
.input-group label {
display: block;
margin-bottom: 8px;
font-weight: 600;
color: #004a99;
}
.input-group input[type="number"],
.input-group input[type="text"] {
width: 100%;
padding: 12px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box; /* Important for padding and width */
font-size: 1rem;
}
button {
width: 100%;
padding: 12px 20px;
background-color: #28a745;
color: white;
border: none;
border-radius: 4px;
font-size: 1.1rem;
font-weight: bold;
cursor: pointer;
transition: background-color 0.3s ease;
margin-top: 10px;
}
button:hover {
background-color: #218838;
}
.result-section {
margin-top: 30px;
padding: 20px;
background-color: #e9ecef;
border-left: 5px solid #004a99;
border-radius: 4px;
}
.result-section h3 {
color: #004a99;
margin-top: 0;
}
#peRatioResult {
font-size: 2rem;
font-weight: bold;
color: #004a99;
display: block; /* Ensures it takes its own line */
margin-top: 10px;
}
.explanation-section {
margin-top: 40px;
padding: 25px;
background-color: #ffffff;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 74, 153, 0.05);
border: 1px solid #e0e0e0;
}
.explanation-section h2 {
text-align: left;
color: #004a99;
margin-bottom: 15px;
}
.explanation-section p,
.explanation-section ul,
.explanation-section li {
margin-bottom: 15px;
color: #555;
}
.explanation-section ul {
list-style-type: disc;
margin-left: 20px;
}
.explanation-section strong {
color: #004a99;
}
/* Responsive adjustments */
@media (max-width: 600px) {
.pe-calc-container {
padding: 20px;
}
h1 {
font-size: 1.8rem;
}
button {
font-size: 1rem;
}
#peRatioResult {
font-size: 1.8rem;
}
}
Price to Earnings (P/E) Ratio Calculator
P/E Ratio Result:
—
Understanding the Price to Earnings (P/E) Ratio
The Price to Earnings (P/E) ratio is one of the most widely used metrics in stock valuation. It helps investors understand how much they are willing to pay for each dollar of a company's earnings. In essence, it's a comparison between a company's stock price and its earnings per share (EPS).
How to Calculate the P/E Ratio
The formula for the P/E ratio is straightforward:
P/E Ratio = Current Stock Price / Earnings Per Share (EPS)
Using our calculator, you simply input the current market price of a single share of a company's stock and its reported Earnings Per Share.
Interpreting the P/E Ratio
Interpreting a P/E ratio requires context and comparison.
- Higher P/E Ratio: Typically suggests that investors expect higher earnings growth in the future, or that the stock is potentially overvalued. Companies with high growth potential often command higher P/E ratios.
- Lower P/E Ratio: Can indicate that a company is undervalued, or that investors expect lower earnings growth in the future. It might also suggest that the company is in a mature industry or facing challenges.
It's crucial to compare a company's P/E ratio to:
- Its historical P/E ratios.
- The P/E ratios of companies within the same industry or sector.
- The P/E ratio of the broader market (e.g., S&P 500 average).
Types of P/E Ratios
There are a few variations, but the most common ones use either trailing or forward earnings:
- Trailing P/E: Uses the EPS from the last four reported quarters (the trailing twelve months). This is what our calculator uses by default.
- Forward P/E: Uses the EPS estimates for the next four quarters. This is more speculative as it relies on future projections.
Example Calculation
Let's say you are looking at Company XYZ:
- The current stock price of Company XYZ is $120.00.
- The company's Earnings Per Share (EPS) over the last twelve months was $5.00.
Using the formula:
P/E Ratio = $120.00 / $5.00 = 24
This means investors are currently willing to pay $24 for every $1 of Company XYZ's earnings. Whether this is a good or bad valuation depends on the industry average, the company's growth prospects, and its historical P/E multiples.
function calculatePE() {
var stockPriceInput = document.getElementById("stockPrice");
var earningsPerShareInput = document.getElementById("earningsPerShare");
var peRatioResultElement = document.getElementById("peRatioResult");
var stockPrice = parseFloat(stockPriceInput.value);
var earningsPerShare = parseFloat(earningsPerShareInput.value);
// Clear previous results and error messages
peRatioResultElement.textContent = "–";
// Input validation
if (isNaN(stockPrice) || isNaN(earningsPerShare)) {
alert("Please enter valid numbers for both Stock Price and Earnings Per Share.");
return;
}
if (stockPrice < 0 || earningsPerShare < 0) {
alert("Stock Price and Earnings Per Share cannot be negative.");
return;
}
if (earningsPerShare === 0) {
// Handle case where EPS is zero. P/E is effectively infinite or undefined.
peRatioResultElement.textContent = "N/A (EPS is zero)";
return;
}
// Calculation
var peRatio = stockPrice / earningsPerShare;
// Display result
// We'll display up to 2 decimal places for clarity, similar to how financial data is often presented.
peRatioResultElement.textContent = peRatio.toFixed(2);
}