Kodiff · embedding

Put a “Compare on Kodiff” button on your site

Send two versions of anything into Kodiff from your own page — and choose which fields get compared. Your text is never uploaded: it travels in the URL fragment or directly between browser tabs, and Kodiff has no server to send it to.

Install

<script src="https://kodiff.com/embed.js"></script>

Two ways to hand off

Pick based on how big the code is. Both keep the text out of every HTTP request.

1. A link — KodiffEmbed.link()

Builds a URL whose payload lives after the #. Browsers never send the fragment to a server, and Kodiff sets Referrer-Policy: no-referrer, so it can't leak that way either. Good for anchors and buttons; the payload is deflated, but keep it under roughly 64KB compressed — mail clients and chat apps truncate long URLs.

const url = await KodiffEmbed.link({
  a: oldXml,
  b: newXml,
  opts: {
    title: "INC0010042 — before/after",
    lang: "xml",
    cleanNames: "sys_id, sys_mod_count, sys_updated_on",
    cleanMode: "ignore"          // hide those fields
  }
});
link.href = url;

2. A tab handoff — KodiffEmbed.open()

Opens Kodiff and passes the payload straight between tabs in memory. No URL length limit, so this is the one for large blocks of code. Must run from a click, or the popup blocker stops it.

btn.addEventListener("click", () => {
  KodiffEmbed.open({
    a: leftText,
    b: rightText,
    opts: {
      title: "catalog_item v1 → v2",
      lang: "xml",
      cleanNames: ["short_description", "state", "priority"],
      cleanMode: "only"            // compare ONLY these fields
    }
  }).catch(console.warn);
});
Choosing the fields. cleanMode: "ignore" hides the fields you name. cleanMode: "only" inverts it — everything else disappears and Kodiff compares only what you listed. For XML and HTML the names are element names, and hiding a parent hides its contents.

Try it

Payload

KeyMeaning
a, bThe two sides, as strings. Required.
opts.titleName shown in Kodiff's title bar.
opts.langxml, json, javascript, html… omit to auto-detect.
opts.cleanNamesComma-separated string, or an array of names.
opts.cleanModeignore hides them · only compares just them.
opts.wsModeall ignores whitespace differences.
opts.ignoreCaseBoolean.
opts.ignoreBlankBoolean — ignore blank lines.
opts.viewlive (side by side) or inline.

What Kodiff does with it

Kodiff only accepts a handoff from the window that opened it, and only carrying a nonce that Kodiff itself generated. It never evaluates anything you send, whitelists every option key, and shows the origin the comparison came from in its status bar.

Limits. A comparison over 5 MB or 50,000 lines is refused rather than left to freeze the tab — line diffing is superlinear in the number of changes. If you're routinely above that, diff on your side and send the interesting region.