Skip to main content
Calcimator

Embedding Calculators

Every calculator on Calcimator is embeddable on your own site via a plain iframe — no API key, no JavaScript SDK, no account required.

Basic embed

Point an iframe at /embed/<category>/<calculator>:

<iframe
  src="https://calcimator.com/embed/loans-debt/debt-payoff-complete"
  width="100%"
  height="600"
  frameborder="0"
  style="border:0;border-radius:8px;"
  loading="lazy"
  referrerpolicy="no-referrer-when-downgrade"
  title="Calcimator"
></iframe>

Category and calculator slugs match the calculator's own page URL (/calculators/<category>/<calculator>). Every calculator's page has an Embed button that generates this snippet for you — see the marketplace for a live generator with a preview.

The height attribute above is just a starting point — the embed reports its real height once it loads, and grows or shrinks to fit automatically if your page listens for it. See Auto-resizing below.

What an embed records

Each embed counts an impression when it loads and a calculation the first time a visitor changes an input. With each count we store the calculator, the time, the embed key (if the snippet has one) and the page that hosts the embed: its scheme, host name and path, for example https://example.com/blog/mortgage-tips.

  • The query string and #fragment are always dropped, and path segments that look like e-mail addresses or tokens are replaced with :redacted.
  • No IP addresses, user agents, cookies or visitor identifiers are stored.
  • The page address comes from the browser's Referer header. The referrerpolicy="no-referrer-when-downgrade"attribute in the snippet lets browsers send the page path to the embed; without it (or in browsers that trim cross-site referrers, such as Safari) only your site's domain is recorded. Remove the attribute, or set referrerpolicy="strict-origin", if you prefer we only see the domain.

Auto-resizing

Every embed posts its actual rendered height to the parent window whenever it changes (loads, an input changes the result, a disclosure opens, the window resizes) — no polling, coalesced to one message per animation frame:

{ "type": "calcimator:embed-size", "height": 842 }

Listen for it and resize the iframe yourself — this is the only way to get a pixel-accurate height instead of a static guess, and it's what removes the need to special-case narrow columns or mobile layouts:

const iframe = document.getElementById("my-calcimator-embed");

window.addEventListener("message", (event) => {
  if (event.origin !== "https://calcimator.com") return;
  if (event.source !== iframe.contentWindow) return; // scope to this embed
  if (event.data?.type !== "calcimator:embed-size") return;
  iframe.style.height = `${event.data.height}px`;
});

The payload is just a height in pixels (no origin-sensitive data), so the message is sent with target origin * — always check event.origin and, if your page embeds more than one calculator, event.sourceyourself before trusting a message. If you don't wire this up, the embed still works — it just stays at whatever fixed height you gave it, same as before this existed.

Share links, printing and saving on your page

After every calculation the embed also posts what the reader entered and what the calculator shows. params holds the inputs that differ from the defaults, the same query values a Calcimator share link carries; inputs and outputs are labelled rows with the value as the embed shows it:

{
  "type": "calcimator:embed-state", "v": 1,
  "calculator": "osha-recordable-rate",
  "params": { "totalIncidents": "4", "hoursWorked": "210000" },
  "inputs": [{ "key": "totalIncidents", "label": "Total Recordable Cases", "value": 4, "display": "4" }, …],
  "outputs": [{ "key": "trir", "label": "TRIR", "value": 3.81, "display": "3.81", "highlight": true }, …]
}

Put paramsin your own page's address bar for share links, and add them to the iframe src when the page loads: the embed reads input values from its query string. Print or save the rows on your own page. Check event.origin and event.source as for the resize message, and ignore a vyou don't know. If your listener starts after the embed has loaded, post { "type": "calcimator:embed-request-state" } to iframe.contentWindow and the embed sends its latest state and height again.

Query parameters

ParamValuesEffect
themelight | darkSets the embed's color scheme. Omit to use the default.
primaryany CSS colorOverrides the primary accent color, e.g. primary=%23059669 (URL-encoded hex). Also accepts bg, fg, card, border, and radius for finer theme overrides.
resultany CSS colorColour of the live result readout (amber by default), with resultFg for text on it. accent, accentFg, muted, mutedFg, cardFg, primaryFg and destructive cover the remaining surfaces, so every colour can match your site.
fontinter | work-sans | figtree | archivo | source-sans-3 | open-sans | roboto | montserrat | nunito | oswald | roboto-slab | source-serif-4 | lora | merriweatherBody text font. headingFont sets headings and numberFont sets results (or numberFont=body to use the body font). Fonts are served by Calcimator, so nothing loads from a third party.
size12 – 20 (px)Base text size inside the embed, to match your page's body text.
pad0 – 3 (rem)Padding around the calculator inside the frame (default 1).
title0Hides the calculator name above the inputs, for pages that already show it.
hidecomma-separated section keysHides one or more supplementary sections — see below.
ekyour embed keyOptional. Links the embed's impressions and usage to your account so they appear on your Embed Analyticspage. Added automatically when you copy embed code from a calculator's Embed dialog while signed in. It's not a secret and changes nothing about how the embed looks or behaves; embeds without it work exactly the same, they just aren't counted for any account.

Hiding sections

Not every embed context wants the full calculator. If your page already has its own chart, or you just want the inputs and headline result in a compact space, hide whatever you don't need with ?hide=:

<!-- Hide the chart and the "how it's calculated" breakdown -->
<iframe src="https://calcimator.com/embed/loans-debt/debt-payoff-complete?hide=chart,steps" ...></iframe>
KeyHides
chartChart — The supplementary recharts chart(s) alongside a result — most simple, comparison, timeline, and wizard calculators, plus Cost of Living's location comparison charts.
visualizationVisualization — A calculator-specific custom visualization (e.g. a diagram or SVG render), where the calculator has one.
tableTable — A data table (e.g. an amortization schedule) — common on timeline calculators like loan/mortgage payoff.
steps“How it's calculated” breakdown — The collapsed “How it's calculated” step-by-step breakdown.
aiExplainerAI explainer — The collapsed “Explain This Result” AI-generated explanation.

A key that doesn't apply to a given calculator (e.g. hide=tableon a calculator with no table) is simply ignored — it's always safe to pass the full set of keys and let each calculator use only the ones that apply to it. Hiding sections shrinks the embed's actual rendered height; if you've wired up Auto-resizingabove, the iframe picks that up automatically — otherwise you'll want to re-measure and reduce your fixed height by hand.

Try it live

Every calculator's marketplace page has an embed generator with checkboxes for width, height, theme, and every section above — the live preview next to it updates as you toggle them, so you can see exactly what your visitors will get before copying the code. Copy it while signed in and the code includes your ekkey, so the embed's stats show up in your dashboard.