Ratio to gain dB calculator
This ratio to gain dB calculator converts a positive linear output-to-input ratio into decibels and makes the convention explicit.
Run — free
Select voltage or amplitude when the ratio compares like field quantities, and select power when it compares powers. The calculator applies 20 times the base-10 logarithm for voltage or amplitude and 10 times the logarithm for power. It returns the multiplier, formula, decibel result, and a plain classification as gain, attenuation, or unity. The computation is deterministic and needs no network connection. It is useful for electronics, audio, RF, measurement, and control work where an ambiguous ratio can otherwise produce a result that is wrong by a factor of two in decibels.
Choose the convention before calculating
Decibels express a ratio on a logarithmic scale, but the correct multiplier depends on what the ratio represents. For a power ratio, use gain in dB equals 10 times log base 10 of Pout divided by Pin. For a voltage ratio, use 20 times log base 10 of Vout divided by Vin when both voltages are measured across equal impedances, or when voltage is being treated as the relevant amplitude quantity. The same twenty-times convention applies to other amplitude or field quantities whose power is proportional to the square of amplitude. That square is why the multiplier doubles: 10 log10 of the squared amplitude ratio simplifies to 20 log10 of the amplitude ratio. Do not select voltage merely because a circuit contains voltages; first identify the ratio actually supplied. If the input is already Pout divided by Pin, choose power. If it is Vout divided by Vin, choose voltage. The calculator also accepts amplitude as an explicit label and treats it like voltage. A dimensionless ratio is required, so numerator and denominator should use matching units before division. For example, divide volts by volts or watts by watts, not volts by millivolts without first reconciling the scale. Making this choice deliberately prevents the common factor-of-two dB error.
Read positive, zero, and negative decibel results
Enter a finite linear ratio greater than zero. A ratio above one means the output quantity exceeds the input quantity, so the returned decibel value is positive and the interpretation is gain. A ratio exactly equal to one produces zero decibels and is classified as unity because output and input are equal. A ratio between zero and one produces a negative value and is classified as attenuation. Zero and negative linear ratios cannot be passed to a real base-10 logarithm, so they return an invalid input error instead of a misleading number. Familiar landmarks help with checking results. A power ratio of two is approximately 3.0103 dB, while an amplitude or voltage ratio of two is approximately 6.0206 dB. A power ratio of ten is 10 dB, and a voltage ratio of ten is 20 dB. In the other direction, a power ratio of one half is approximately negative 3.0103 dB, while a voltage ratio of one half is approximately negative 6.0206 dB. The response echoes the normalized ratio type, reports whether the multiplier was ten or twenty, and includes the applied formula. Results are rounded to a stable significant precision so fixtures and repeated calculations remain consistent while preserving useful engineering accuracy. Each successful API calculation costs $0.002.
Apply the result without mixing reference conditions
Use the calculated value only after confirming that numerator and denominator describe comparable conditions. Voltage gain expressed with 20 log10 is straightforward for the same circuit ports when their reference impedances are equal or when voltage gain itself is the intended specification. If input and output impedances differ and the real question concerns power transfer, a voltage ratio alone does not establish the power ratio. You must account for impedance and then apply 10 log10 to the resulting power ratio. This distinction matters in RF systems, transmission lines, audio interfaces, sensors, and amplifiers connected to different loads. Similarly, this calculator converts a pure ratio; it does not calculate absolute levels such as dBm, dBW, dBV, or sound pressure level, all of which require a defined reference quantity. It also does not infer whether a number came from peak, RMS, peak-to-peak, or another amplitude definition. Use the same definition on both sides of the ratio so common scaling factors cancel. For cascaded stages, decibel gains may be added after each stage has been computed with the correct convention, while linear ratios would be multiplied. Negative decibels describe attenuation rather than an invalid circuit, and zero decibels means unity rather than no signal. Treat the returned formula and multiplier as an audit trail: they make it easy to review spreadsheets, lab notes, design calculations, and test expectations for convention mistakes.
What you can do with it
Amplifier voltage gain
Convert a measured Vout-to-Vin ratio into dB with the 20 log10 amplitude convention.
Power-chain analysis
Express a transmitter, filter, or load power ratio in dB with the 10 log10 power convention.
Attenuator verification
Turn a fractional linear ratio into a negative decibel value and confirm expected loss.
FAQ
Why does voltage use 20 log10?
For equal impedance, power is proportional to voltage squared, so 10 log10 of the squared voltage ratio becomes 20 log10 of the voltage ratio.
Why does power use 10 log10?
The decibel is defined directly from a power ratio as 10 times its base-10 logarithm.
What does a negative gain in dB mean?
It means attenuation: the positive linear ratio is below one, so the output quantity is smaller than the input quantity.
Can the ratio be zero?
No. A real logarithm requires a positive ratio, and a zero ratio would tend toward negative infinity rather than a finite dB result.
Can I use 20 log10 for voltage when impedances differ?
You can report voltage gain that way, but it does not by itself describe power gain. Include impedance when the intended comparison is transferred power.
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/elec/ratio-to-gain-db \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"ratio":2,"ratio_type":"voltage"}'const res = await fetch("https://api.kit.forhosting.com/elec/ratio-to-gain-db", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"ratio": 2,
"ratio_type": "voltage"
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/elec/ratio-to-gain-db",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"ratio": 2,
"ratio_type": "voltage"
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/elec/ratio-to-gain-db", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"ratio":2,"ratio_type":"voltage"}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"ratio":2,"ratio_type":"voltage"}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/elec/ratio-to-gain-db", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"ratio": 2,
"ratio_type": "voltage"
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "elec.ratio_to_gain_db",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |