Skip to content
Rabanser Consulting
Facebook

Web tools · Calculator design

How to build an online calculator

By Last reviewed

A useful calculator lets readers check where the number came from. Define the inputs and result before designing the form, then verify the tool against calculations you can do by hand.

Define the decision, inputs and units

Write down the decision the tool supports. A paint calculator can estimate litres for a surface and number of coats. It needs the area in square metres, coverage in square metres per litre and the number of coats. Say where the coverage estimate comes from and let readers replace it with the value on their product label.

Keep units visible beside the inputs and the result. Explain what a default represents, and keep a blank field distinct from zero. If the tool supports multiple unit systems, convert to one consistent unit before applying the formula.

Show a calculation readers can repeat

In this fictional example, an area of 25 m², coverage of 8 m² per litre and two coats give 25 × 2 ÷ 8 = 6.25 litres. That is an estimate before allowing for waste, absorbency or buying whole tins. If the tool calculates how much to buy, show that as a separate result with its own rounding rule.

Display the inputs used next to the result. When a field changes, recalculate or clearly mark the previous estimate as out of date. Publish the formula and a worked example as ordinary page text so visitors can still understand the method if scripts fail.

Test values that can break the result

  • Normal case: use 25, 8 and 2 to reproduce 6.25 litres.
  • Invalid denominator: a coverage of zero gets a field-level error and no estimate.
  • Missing or impossible input: an empty area or negative number of coats gets a specific explanation.
  • Decimal input: enter a fractional value using the punctuation expected by each language. Check the actual numeric value and the formatting of the result.
  • Keyboard and screen reader: use labelled fields, keep corrections reachable and make errors and new results perceivable without relying on colour.

If inputs reach a server, validate them on the server too. Keep any personal details out of the tool unless they are necessary to answer the question.

Example from ReadyRudi

The ReadyRudi water calculator for people and pets is a live example from the ReadyRudi project. It gives households a way to change the people, pets and planning period behind their estimate. That makes the assumptions visible when comparing two scenarios. The example illustrates the design of the tool. Use the relevant official guidance for emergency preparedness.