# Put a calculator on your own page

> Put any of 1181 construction calculators on your own page. Pick one, choose a theme and width, copy the snippet. Free, no key, with a postMessage channel…

Page: https://craftquantities.com/embeds/ (page). This is the page's Markdown copy; the HTML page is the canonical version.

Any of the 1,181 calculators here can run inside your page. It is free, there is no key and no quota, and the maths is the same code this site runs — not a cut-down copy that drifts.

- 1,181 Calculators to choose from
- 3 Themes
- 3 Starting widths

## Build your snippet

1,181 calculators

**Format**

The whole calculator: every input, the breakdown, sources and notes.

**Theme**

**Units**

**Width**

The height is only the starting size — what a host sees before any script runs. The frame measures itself and posts its real height; with automatic fitting on, the snippet applies it. The fit button above is this page reading that same message.

## Your snippet

```
<iframe src="https://craftquantities.com/embed/?calc=concrete-calculator" width="100%" height="900" loading="lazy" style="border:1px solid #e4e4e7;border-radius:12px;max-width:100%" title="Concrete Calculator — Craft Quantities"></iframe>
<p style="margin:4px 0 0;font:12px/1.4 system-ui,sans-serif">Calculator by <a href="https://craftquantities.com/calculators/materials-quantities/concrete-calculator/">Craft Quantities</a></p>
```

Paste it where the calculator should appear. The second line is the credit link the terms below ask you to keep.

## Live preview

The real frame, from the real address — not a mock-up.

Waiting for the frame to report its height…

## Ready-made sets

Pick the kind of site you run. Each set is a few calculators in the format that suits it. Copy one, or the whole set, or open any of them in the builder to change the theme, units and inputs.

A small tool inside a how-to post: the reader types two numbers and gets the shopping list quantity, with a link to the full calculator.

- Paint Calculator Compact

  Under a room-painting post: litres or gallons for a room.

  [Customise](https://craftquantities.com/embeds/#calculator=paint-calculator&format=compact)
- Deck Board Calculator Compact

  In a deck build-along: boards for the deck surface.

  [Customise](https://craftquantities.com/embeds/#calculator=deck-board-calculator&format=compact)
- Flooring Calculator Compact

  In a floor-laying guide: boxes to buy.

  [Customise](https://craftquantities.com/embeds/#calculator=flooring-calculator&format=compact)
- Fence Calculator Compact

  In a fence project post: posts, rails and pickets.

  [Customise](https://craftquantities.com/embeds/#calculator=fence-calculator&format=compact)
- Mulch Calculator Mini

  In the sidebar of a garden blog: volume of mulch for a bed.

  [Customise](https://craftquantities.com/embeds/#calculator=mulch-calculator&format=mini)
- Topsoil Calculator Mini

  Beside a raised-bed post: volume of soil to fill it.

  [Customise](https://craftquantities.com/embeds/#calculator=topsoil-calculator&format=mini)

## Example host pages

What each format looks like on a page that is not ours, with the snippet exactly as the builder writes it. The line under the frame is the credit link: ordinary HTML on your page, visible, pointing at the calculator’s page.

Inside an article column, 360 px and wider. The button under the result opens the full calculator.

Your site · Home · Projects · Contact

Painting a room: the quantity

Type the room's two main measurements below. The answer shows in both unit systems and the full calculator is one tap away if you want the rest.

Calculator by [Craft Quantities](https://craftquantities.com/calculators/renovation-construction/paint-calculator/)

### The markup on the host page

```
<iframe src="https://craftquantities.com/embed/?calc=paint-calculator&theme=light&ev=1&fmt=compact" width="100%" height="460" loading="lazy" style="border:1px solid #e4e4e7;border-radius:12px;max-width:100%" title="Paint Calculator — Craft Quantities"></iframe>
<p style="margin:4px 0 0;font:12px/1.4 system-ui,sans-serif">Calculator by <a href="https://craftquantities.com/calculators/renovation-construction/paint-calculator/">Craft Quantities</a></p>
```

Nothing else is needed: no key, no script (the fitting script is optional), no cookie. The frame carries no ads and no analytics, and its policy forbids loading either.

## WordPress plugin

On a WordPress site, the free plugin does the pasting for you: a block with a searchable list of every calculator, settings for units, theme and height, and a shortcode for the classic editor. It embeds this page’s frame, fits its height automatically and adds no tracking of its own.

[Download the plugin (zip)](https://craftquantities.com/downloads/craft-quantities.zip)

Version 1.1.0, for WordPress 6.0 or later and PHP 7.4 or later. Licensed GPL-2.0-or-later; the calculators it shows stay under CC BY 4.0. Not in the WordPress.org directory yet.

1. Download the plugin zip.
2. In WordPress, open Plugins, then Add New, then Upload Plugin, choose the zip and install it.
3. Activate “Craft Quantities Calculators”.
4. Add the “Craft Quantities Calculator” block and pick a calculator from the searchable list, or type the shortcode in the classic editor.

Shortcode

```
[craftquantities calc="concrete-calculator" units="imperial" theme="auto" height="auto"]
```

Every embed shows “Calculator by Craft Quantities” under the frame, linking to the calculator’s full page; each block can make that link nofollow.

## Three formats, one address

- Full Any width

  The whole calculator as it opens here: every input, the breakdown, notes and sources. Snippets made before the formats existed are full frames and stay exactly as they were.
- Compact 360 px and up

  Up to 4 inputs, the headline answer in metric and imperial, the breakdown rows you pick, and a button that opens the full calculator in a new tab with the reader's values filled in.
- Mini 250–350 px

  A sidebar box: one or two inputs and one large result, with the other unit system underneath and a link to the full calculator.

Every format posts the same `ready`, `result` and `size` messages, so automatic fitting and your own listener work unchanged. A compact or mini frame’s `result` carries the value the full calculator would post for the same inputs. Calculators that need a rate of your own, or that work from choices rather than numbers, show a link to the full calculator in the smaller formats.

### The credit link, and what is not in a frame

- The snippet ends with one line of your page’s own HTML, “Calculator by Craft Quantities”, linking to the calculator’s page. The words are our name, not a keyword. It is visible and it is in your page, so search engines can see it; keep it visible.
- If your site marks every outbound link `rel="nofollow"`, tick that box in the builder and the line is written that way. The link stays; your policy decides how it is counted. Please do not hide, shrink or remove the line, and do not point it anywhere else.
- The frame also carries its own “Full version & sources” link (or “By Craft Quantities” in the mini format). It is inside the frame, so it is for your readers; the line on your page is the one that counts as a link from your site.
- There are no ads in a frame and no analytics, cookies or third-party requests. The frame is served with its own content security policy: scripts only from this site and no connection to any other host, so a change to the rest of the site could not put an ad or a measuring script into one.

### The frame’s parameters

The builder writes these for you. A value the frame cannot read is ignored and the default used, never an error.

| Parameter | Values | What it does |
|---|---|---|
| `calc` | a calculator slug | Required. Which calculator the frame runs. |
| `theme` | light \| dark | Forces the scheme. Absent, the frame follows the reader's device. |
| `cq.u` | metric \| imperial | Pins the unit system. Absent, the reader's locale decides. |
| `heading` | 0 | Leaves out the frame's own heading. |
| `ev` | 1 | The parameter version. Every parameter below is read only with it; a version the frame does not know draws the full calculator. |
| `fmt` | compact \| mini | The format. Absent or unknown, the full calculator. |
| `in` | id,id | The inputs shown, in order. Unknown ids are dropped and the count is capped; with none left, the frame picks its own. |
| `s.<id>` | a number | A starting value in the calculator's metric units, held to the input's own limits. The reader can change it. |
| `x.<id>` | a number | A fixed value, metric, held to the input's limits. The input is hidden, its value always used and named under the result. |
| `rows` | 0,1 \| empty | The breakdown rows printed, by position. Empty prints none. Absent: compact prints the first two, mini none. |

## Reading the result from your page

The frame posts every recompute to your page. This is what makes it worth wiring into a quote form rather than just dropping on a blog post.

**`ready`**

— posted once, with the calculator’s slug, title and canonical URL.

**`result`**

— posted on every recompute, with the unrounded value, its unit and the breakdown lines where the calculator produces them.

**`size`**

— posted whenever the frame’s height changes.

**The channel is one-way.** The frame posts and never acts on what it receives, because it is embedded on pages this site has never heard of and so has no origin to validate a sender against. Check `event.source` against your frame’s `contentWindow` in your listener: a page’s window is a shared bus, and analytics, chat widgets and video players all post into it — any of them could spell `source` the same way.

Your page’s listener

```
const frame = document.querySelector("#cq-frame");

window.addEventListener("message", (event) => {
  // Only this frame's window, and only a message of ours.
  if (event.source !== frame.contentWindow) return;
  if (event.data?.source !== "craft-quantities") return;

  if (event.data.type === "result") {
    // A number: set it as a value, never as HTML.
    document.querySelector("#quantity").value = event.data.value;
  }

  if (event.data.type === "size" && Number.isFinite(event.data.height)) {
    frame.style.height = Math.ceil(event.data.height) + "px";
  }
});
```

Every message is an object with `source: "craft-quantities"`, `version: 1`, `type` and `slug`. A `size` message adds `height`, in CSS pixels; a `result` adds `value`, `unit` and, where there is one, `breakdown`. The builder’s fitting script is this check, ready-made, for every frame on the page at once:

```
<script>(function(){if(window.cqEmbedFit)return;window.cqEmbedFit=1;window.addEventListener("message",function(e){var d=e.data;if(!d||d.source!=="craft-quantities"||d.type!=="size"||typeof d.height!=="number"||!isFinite(d.height))return;var f=document.getElementsByTagName("iframe");for(var i=0;i<f.length;i++){if(f[i].contentWindow!==e.source)continue;var a=document.createElement("a");a.href=f[i].src;if(a.protocol+"//"+a.host!==e.origin)return;f[i].style.height=Math.min(6000,Math.max(200,Math.ceil(d.height)))+"px";return}})})();</script>
```

## The terms, in full

- Free, commercial use included.

  No key, no quota, no tracking of who embeds what. No ads inside a frame, and no analytics or cookies either.
- The attribution link stays.

  Every frame carries one visible link back to the full calculator, and the snippet adds a plain line of your own page's HTML that links to the same page. It is the whole reason this is free; removing or hiding it is the one thing that is not allowed. If your site marks outbound links nofollow, the builder writes that too.
- It is a calculator, not advice.

  The frame carries the same estimate disclaimer the full page does. Do not present a result as a specification.
- Nothing is sent anywhere.

  The frame computes in the reader’s browser. Your readers’ inputs do not reach this site or anyone else.

[Prefer to work with the data directly? There is a free static JSON API](https://craftquantities.com/api/)

---
Source: https://craftquantities.com/embeds/
Craft Quantities: free to read, cite and link to; the pages are not licensed for republication. Quantities only: no prices, no design and no certification.
