Unit converter template
Length, weight, volume and temperature in one form. Drop-down values carry the unit sizes, so one formula converts anything.
Try the live Unit converter first- Import-ready Gravity Forms JSON
- One-page install guide
- The plugins it needs, with links
- Everything in Template
- Step-by-step PDF with screenshots of every field and formula
- The CSS skin from this site, with notes on matching your brand
What you'll need
Check these before you buy so there are no surprises. Links may be affiliate links.
- Required Gravity Forms (any license) Calculation fields, drop-down values and conditional logic are in core.
Free build guide: Unit converter for WordPress
This guide rebuilds the Unit converter from this site in Gravity Forms: 12 inputs, 9 live results and no submit button. Expect about 63 minutes by hand. The template above is the same form as an import file, and the bundle adds a PDF version of this guide with a screenshot of every setting, plus the stylesheet.
You will end up with:
- Result
- Result
- Result
- Fahrenheit (°F)
- Kelvin (K)
- Celsius (°C)
- Kelvin (K)
- Celsius (°C)
- Fahrenheit (°F)
What you need
- Gravity Forms (any license) — Calculation fields, drop-down values and conditional logic are in core.
Everything here is core Gravity Forms. No add-ons.
1. Create the form
- Go to Forms → New Form and name it Unit converter.
- In Form Settings → Form Layout, set the CSS Class Name to
fo-live-only. Step 3 uses it to hide the submit button. - Leave the form open in the editor; the fields come next.
2. Add the fields, in this order
Field IDs are assigned as you add fields. If yours come out differently, change the {Label:ID} references in the formulas to match your IDs. Settings not mentioned stay at their defaults.
1. Convert · Radio Buttons · ID 1
Custom CSS Class (Appearance tab) fo-segmented.
Choices (tick show values and enter each value):
- Length — value
length(selected by default) - Weight — value
weight - Volume — value
volume - Temp — value
temp
2. Amount · Number · ID 2
Number Format 9,999.99; Default Value 10; Conditional Logic (Advanced tab): Show this field if Convert is Length..
3. From · Drop Down · ID 3
Layout: half width, on the same row as its neighbour (drag the field beside it in the editor; no CSS class needed); Conditional Logic (Advanced tab): Show this field if Convert is Length..
Choices (tick show values and enter each value):
- Millimetres (mm) — value
0.001 - Centimetres (cm) — value
0.01 - Metres (m) — value
1 - Kilometres (km) — value
1000 - Inches (in) — value
0.0254 - Feet (ft) — value
0.3048(selected by default) - Yards (yd) — value
0.9144 - Miles (mi) — value
1609.344
4. To · Drop Down · ID 4
Layout: half width, on the same row as its neighbour (drag the field beside it in the editor; no CSS class needed); Conditional Logic (Advanced tab): Show this field if Convert is Length..
Choices (tick show values and enter each value):
- Millimetres (mm) — value
0.001 - Centimetres (cm) — value
0.01 - Metres (m) — value
1(selected by default) - Kilometres (km) — value
1000 - Inches (in) — value
0.0254 - Feet (ft) — value
0.3048 - Yards (yd) — value
0.9144 - Miles (mi) — value
1609.344
5. Result · Number · ID 5
Number Format 9,999.99; Custom CSS Class (Appearance tab) fo-result; tick Enable Calculation, Rounding 4; Conditional Logic (Advanced tab): Show this field if Convert is Length..
{Amount:2} * {From:3} / {To:4}
6. Amount · Number · ID 6
Number Format 9,999.99; Default Value 150; Conditional Logic (Advanced tab): Show this field if Convert is Weight..
7. From · Drop Down · ID 7
Layout: half width, on the same row as its neighbour (drag the field beside it in the editor; no CSS class needed); Conditional Logic (Advanced tab): Show this field if Convert is Weight..
Choices (tick show values and enter each value):
- Milligrams (mg) — value
0.001 - Grams (g) — value
1 - Kilograms (kg) — value
1000 - Metric tons (t) — value
1000000 - Ounces (oz) — value
28.349523125 - Pounds (lb) — value
453.59237(selected by default) - Stone (st) — value
6350.29318
8. To · Drop Down · ID 8
Layout: half width, on the same row as its neighbour (drag the field beside it in the editor; no CSS class needed); Conditional Logic (Advanced tab): Show this field if Convert is Weight..
Choices (tick show values and enter each value):
- Milligrams (mg) — value
0.001 - Grams (g) — value
1 - Kilograms (kg) — value
1000(selected by default) - Metric tons (t) — value
1000000 - Ounces (oz) — value
28.349523125 - Pounds (lb) — value
453.59237 - Stone (st) — value
6350.29318
9. Result · Number · ID 9
Number Format 9,999.99; Custom CSS Class (Appearance tab) fo-result; tick Enable Calculation, Rounding 4; Conditional Logic (Advanced tab): Show this field if Convert is Weight..
{Amount:6} * {From:7} / {To:8}
10. Amount · Number · ID 10
Number Format 9,999.99; Default Value 1; Conditional Logic (Advanced tab): Show this field if Convert is Volume..
11. From · Drop Down · ID 11
Layout: half width, on the same row as its neighbour (drag the field beside it in the editor; no CSS class needed); Conditional Logic (Advanced tab): Show this field if Convert is Volume..
Choices (tick show values and enter each value):
- Millilitres (ml) — value
1 - Litres (l) — value
1000 - Teaspoons (tsp) — value
4.92892159375 - Tablespoons (tbsp) — value
14.7867647813 - Fluid ounces (fl oz) — value
29.5735295625 - Cups — value
236.5882365 - Pints (pt) — value
473.176473 - Quarts (qt) — value
946.352946 - Gallons (gal) — value
3785.411784(selected by default) - Cubic feet (cu ft) — value
28316.846592
12. To · Drop Down · ID 12
Layout: half width, on the same row as its neighbour (drag the field beside it in the editor; no CSS class needed); Conditional Logic (Advanced tab): Show this field if Convert is Volume..
Choices (tick show values and enter each value):
- Millilitres (ml) — value
1 - Litres (l) — value
1000(selected by default) - Teaspoons (tsp) — value
4.92892159375 - Tablespoons (tbsp) — value
14.7867647813 - Fluid ounces (fl oz) — value
29.5735295625 - Cups — value
236.5882365 - Pints (pt) — value
473.176473 - Quarts (qt) — value
946.352946 - Gallons (gal) — value
3785.411784 - Cubic feet (cu ft) — value
28316.846592
13. Result · Number · ID 13
Number Format 9,999.99; Custom CSS Class (Appearance tab) fo-result; tick Enable Calculation, Rounding 4; Conditional Logic (Advanced tab): Show this field if Convert is Volume..
{Amount:10} * {From:11} / {To:12}
14. Temperature · Number · ID 14
Number Format 9,999.99; Default Value 72; Layout: half width, on the same row as its neighbour (drag the field beside it in the editor; no CSS class needed); Conditional Logic (Advanced tab): Show this field if Convert is Temp..
15. From · Drop Down · ID 15
Layout: half width, on the same row as its neighbour (drag the field beside it in the editor; no CSS class needed); Conditional Logic (Advanced tab): Show this field if Convert is Temp..
Choices (tick show values and enter each value):
- Celsius (°C) — value
c - Fahrenheit (°F) — value
f(selected by default) - Kelvin (K) — value
k
16. Fahrenheit (°F) · Number · ID 16
Number Format 9,999.99; Custom CSS Class (Appearance tab) fo-result; tick Enable Calculation, Rounding 2; Conditional Logic (Advanced tab): Show this field if Convert is Temp and From is Celsius (°C)..
{Temperature:14} * 9 / 5 + 32
17. Kelvin (K) · Number · ID 17
Number Format 9,999.99; Custom CSS Class (Appearance tab) fo-result fo-result--sub; tick Enable Calculation, Rounding 2; Conditional Logic (Advanced tab): Show this field if Convert is Temp and From is Celsius (°C)..
{Temperature:14} + 273.15
18. Celsius (°C) · Number · ID 18
Number Format 9,999.99; Custom CSS Class (Appearance tab) fo-result; tick Enable Calculation, Rounding 2; Conditional Logic (Advanced tab): Show this field if Convert is Temp and From is Fahrenheit (°F)..
( {Temperature:14} - 32 ) * 5 / 9
19. Kelvin (K) · Number · ID 19
Number Format 9,999.99; Custom CSS Class (Appearance tab) fo-result fo-result--sub; tick Enable Calculation, Rounding 2; Conditional Logic (Advanced tab): Show this field if Convert is Temp and From is Fahrenheit (°F)..
( {Temperature:14} - 32 ) * 5 / 9 + 273.15
20. Celsius (°C) · Number · ID 20
Number Format 9,999.99; Custom CSS Class (Appearance tab) fo-result; tick Enable Calculation, Rounding 2; Conditional Logic (Advanced tab): Show this field if Convert is Temp and From is Kelvin (K)..
{Temperature:14} - 273.15
21. Fahrenheit (°F) · Number · ID 21
Number Format 9,999.99; Custom CSS Class (Appearance tab) fo-result fo-result--sub; tick Enable Calculation, Rounding 2; Conditional Logic (Advanced tab): Show this field if Convert is Temp and From is Kelvin (K)..
( {Temperature:14} - 273.15 ) * 9 / 5 + 32
3. Hide the submit button
The results are live, so nothing needs submitting. Add this filter to your theme’s functions.php or a code-snippets plugin; it hides the button on any form carrying the fo-live-only class:
add_filter( 'gform_submit_button', function ( $button, $form ) {
return str_contains( (string) rgar( $form, 'cssClass' ), 'fo-live-only' ) ? '' : $button;
}, 10, 2 );
Or with CSS alone: .fo-live-only_wrapper .gform_footer { display: none; }
4. Put it on a page and make it look like this
Add the form to any page with the Gravity Forms block, or the shortcode [gravityform id="X" title="false" ajax="false"]. The form inherits your theme’s styles; the classes you set in step 2 are hooks for the look you see on this site:
fo-resulton a calculation field makes it the big teal result panel.fo-result fo-result--submakes the smaller secondary figures.fo-segmentedon a radio field turns it into a segmented switch.- Two fields on one row is the editor’s own column layout: drag a field beside another and the row splits in half. No CSS class is needed, and the old
gf_left_halfReady Classes are deprecated.
The bundle includes the two stylesheets that implement those classes, with notes on matching your brand colours. Without them the form still works; it just looks like your theme’s default Gravity Forms styling.
How the maths works is explained under “How it’s calculated” on the live Unit converter.