kar-canon

Canonical JSON equivalence prover. Paste two JSON documents that should mean the same thing — different key order, whitespace, or number formatting — and get a byte-identical canonical hash if, and only if, they truly encode the same data. If they don't, it points at exactly where they diverge.
runs offline single file, no server no AI judge SHA-256 via crypto.subtle third-party re-runnable

Start here

Kar-Canon tells you whether two JSON documents carry exactly the same data, however they are formatted, and where they differ when they do not. It runs entirely in this page: nothing you paste is sent anywhere, and no AI judges anything.

  1. Paste document A and document B above, or press one of the Load example buttons.
  2. Press Canonicalize & compare.
  3. Read the verdict: MATCH means the same data; DIFFER lists every path where a value was added, removed or changed.
  4. Keep the fingerprints: the SHA-256 of each canonical form, which anyone can recompute.

Below the tool: how it works · words on this page · blueprint · roll it out · for a business · FAQ

What this proves

AI pipelines re-serialize the same structured decision (a tool call, a policy verdict, a cached response) through different libraries, languages, and formatters. Key order shifts, whitespace changes, 1.50 becomes 1.5 — and a naive string or byte comparison flags a false mismatch, or worse, a naive "looks similar" check misses a real one.

kar-canon converts each document to a single, fully-specified canonical byte string (closely following RFC 8785, the JSON Canonicalization Scheme), hashes it with SHA-256, and compares hashes. Anyone — in any language — can re-implement the algorithm below and reproduce the identical hash from the identical data. There is no model in the loop and nothing to trust but the arithmetic.

Limits: what it does not check

Algorithm — reproduce this hash yourself
  1. Parse the input as JSON (RFC 8259). Reject on parse failure.
  2. Canonicalize recursively:
    • null, true, false → the literal token.
    • number → the ECMAScript Number::toString form (shortest round-tripping decimal any compliant JS engine produces); negative zero canonicalizes to 0.
    • string → a JSON string literal with only the mandatory escapes (", \, and control characters U+0000–U+001F); every other code point is emitted as literal UTF-8, unescaped.
    • array → [ + canonicalized elements, comma-separated, original order preserved + ].
    • object → keys sorted by UTF-16 code unit order, duplicates resolved last-wins, then { + "key":value pairs, comma-separated, no extra whitespace + }.
  3. UTF-8 encode the resulting canonical string.
  4. SHA-256 the bytes; render the digest as lowercase hex.

Compare two documents

Self-test

Ten built-in cases exercise the exact same canonicalize / hash / diff functions used above — including one that must verify (equivalent documents, superficially different) and one that must be caught (a tampered value). Nothing here is hand-picked after the fact: the assertions and the engine are the same code that runs your input above.

How it works

JSON A and Bone canonical formSHA-256 of eachMATCH, or DIFFERwith every path
  1. Each document is parsed and rewritten in one canonical form, aligned with RFC 8785: keys sorted, every number and string in one spelling, no whitespace.
  2. Each canonical form is hashed with SHA-256. Equal hashes mean equal data, whatever the formatting, key order, number spelling or escapes.
  3. When they differ, it walks both documents and lists every path where they part.

Words on this page

Canonical form
One agreed way of writing the same data: keys in sorted order, no spaces, each number and string in one spelling. {"b":1, "a":1.50} becomes {"a":1.5,"b":1}.
Path
Where a value sits in the document: $.order.items[2].price is the price of the third item in the order.
Kernel
The small piece of code that decides every verdict; the rest of the page only shows what it decided. Here it is the block inside this page, copied byte for byte into kernel.mjs (the file the tests run) and into the script, so all three are the same code.
SHA-256 receipt
A 64-character fingerprint of the input and the verdict. Anyone with the same input gets the same fingerprint; change one character and it changes completely.
Deterministic
No AI model, no random numbers and no clock go into a verdict, so the same input gives the same verdict on any machine, every time.
No AI judge
No language model decides anything. The verdict comes from fixed rules you can read in kernel.mjs.
Mutation gate
A test of the tests. witness makes small deliberate changes to the kernel, one at a time: for example it turns if (count > 0) into if (count >= 0), then runs the tests. Every change must make a test fail. A change no test notices has survived: it would mean no test checks what happens at that exact point. A change reviewed as equivalent cannot alter any result (both versions give the same answer for every input), and the reason is written down and checked.
CI
Continuous integration: GitHub re-runs every test and the gate on its own computers on every change, and the runs are public.
In the browser
The page does the work on your computer. Nothing you paste is sent to a server.
MIT licence
An open-source licence: you may use, copy, change and build products with it, free, as long as the copyright notice stays.
Sourced figures
Every number in the cost case comes from a published source (the UK median wage and UK inflation, from the ONS), linked under the table.

Blueprint

Roll it out

  1. Pick one place where this check is done by hand today, or skipped, and the person who owns it.
  2. Try it here on real examples from that place. Nothing leaves the page.
  3. Put it in the flow. Run node scripts/kar-canon.mjs a.json b.json in CI or a script (Node.js 20 or later, no dependencies). Exit code 0 means MATCH, 1 means DIFFER, 2 means the input could not be read. An AI agent can run the same script as a skill.
  4. Keep the receipts with the work they checked, so anyone can recompute a verdict later.
  5. Measure the difference with the cost case below.

For a business

Kar-Canon turns a check that is usually done by eye, or not at all, into a verdict anyone can recompute: the same input gives the same answer and the same SHA-256 receipt on any machine, with no AI judging it.

The cost case, on your numbers

What the checking costs today against running the tool. Staff time is at the UK median hourly wage with on-costs left out, so this is a floor; later years rise with UK inflation (CPI). Change any box to your own numbers and the table recalculates as you type.

How it is worked out. Today: checks a year (per week × 52) × minutes per check × the median hourly wage, plus anything you pay for a tool now. With the tool: the share it replaces takes the seconds you enter instead of the minutes, and the rest is still checked by hand. Each later year rises by one more year of inflation.

yearchecking by handwith Kar-Canonsaved

Against what you do now

Security, data protection and deployment

Support and ownership

Supplied by AI Native Solutions; start through that site. Support, any service level, warranty and liability are agreed per deployment, in each deployment's agreement. The software is MIT and keeps running without us.

Where it stops, answered straight

The case for the board

A check that anyone can recompute replaces a check that has to be trusted, at no licence cost, without sending your data anywhere. Its logic is the code on this page, and its tests are themselves tested.

FAQ

Is it the same as a text diff?
No. A text diff compares characters; this compares data. Two files that differ only in formatting, key order or number spelling MATCH.
Can an agent run it?
Yes. The same kernel ships as a one-file Node.js script (scripts/kar-canon.mjs) with no dependencies, usable as an agent skill or a CI step.
What happens with bad, empty or very large input?
Text that is not valid JSON is refused with the parser's own message (the script exits 2); nothing is guessed. Numbers too large or too precise for a double are rounded first (see Limits). JSON nested more than about 2,500 levels deep stops with an error (the script exits 3), never with a verdict. There is no size cap beyond your machine's memory.
What do I need to run it?
For the page, a modern browser; there is nothing to install. For the script, Node.js 20 or later (free from nodejs.org; node --version shows which one you have): download scripts/kar-canon.mjs (one file, no dependencies, no npm install) and run it with no arguments to see how to call it.
Does it need the internet or an account?
No. The page works once loaded, and the script runs offline. Nothing is uploaded.