Skip to content

Menu

JSON Canonicalizer (JCS)

Turn JSON into its RFC 8785 canonical form: sorted keys, no whitespace, ECMAScript number format. See the bytes and SHA-256, and catch duplicate keys.

Runs entirely in your browserJSON ToolsFree, no sign-up
Loading tool

01What is JSON Canonicalizer (JCS)?

JSON Canonicalizer turns JSON into one fixed byte form using the JSON Canonicalization Scheme, RFC 8785 (JCS). The same data can be written as JSON in many ways: keys in any order, spaces or none, 4.50 or 4.5, \u0041 or A. That is a problem when you hash or sign JSON, because two equal objects give different hashes. JCS fixes it with three rules. Primitive values are written the way ECMAScript's JSON.stringify writes them. Object members are sorted by their names as UTF-16 code units, recursively, and there is no whitespace. The result is then encoded as UTF-8. Paste JSON and the tool shows the canonical text, its length in bytes, its SHA-256 hash and, if you like, the bytes in hex. The tool uses its own parser, so it can enforce the I-JSON input rules (RFC 7493) that RFC 8785 requires. Duplicate property names are an error, since JSON.parse would silently keep the last one. Strings containing a lone surrogate are an error too, because they aren't valid Unicode. Numbers that overflow a double are rejected. Integers above 2^53 trigger a warning, because they lose precision; the RFC's Appendix D suggests sending such numbers as strings. The tool's output matches the RFC's own samples. The section 3.2.2 object with "numbers": [333333333.33333329, 1E30, 4.50, 2e-3, 0.000000000000000000000000001] becomes {"literals":[null,true,false],"numbers":[333333333.3333333,1e+30,4.5,0.002,1e-27],"string":"€$\u000f\nA'B\"\\\\\"/"}. That is byte for byte the hex listed in section 3.2.4. The sorting test in section 3.2.3 puts "\r" first, then "1", and the emoji key before the Hebrew letter, because sorting uses UTF-16 code units, not code points. The number samples in Appendix B also come out right, for example 1e+21, 0.000001 and 1424953923781206.2. JCS is used where JSON needs a stable hash before signing, for example in the W3C Data Integrity eddsa-jcs-2022 cryptosuite. The tool only canonicalizes and hashes; it doesn't sign anything or hold keys. All processing happens in your browser. Sources: RFC 8785, JSON Canonicalization Scheme (https://www.rfc-editor.org/rfc/rfc8785), including the samples in sections 3.2.2 to 3.2.4 and Appendix B; RFC 7493, I-JSON (https://www.rfc-editor.org/rfc/rfc7493); W3C Data Integrity EdDSA Cryptosuites (https://www.w3.org/TR/vc-di-eddsa/).

Developers who sign or hash JSON: webhook providers, identity and verifiable credential developers, and anyone writing a JCS library. The tool runs entirely in your browser, so your data never leaves your device.

02How to use JSON Canonicalizer (JCS)

  1. Paste the JSON document
  2. Fix anything reported as an error, such as duplicate property names
  3. Copy the canonical JSON or its SHA-256 hash
  4. Tick Show UTF-8 bytes to compare the exact bytes with another implementation

03Worked examples

Input: {"b": 2, "a": [1.0, "x", 1e21, 0.1]}
Result: {"a":[1,"x",1e+21,0.1],"b":2} SHA-256 683f0b293e9e59c556c0dd4fa71fe508e0f9d3f73844a33eb81018ad86d0c447
Keys sorted, 1.0 becomes 1, 1e21 is written as 1e+21.
Input: {"amount": 1999.00, "currency": "EUR", "id": "in_123"}
Result: {"amount":1999,"currency":"EUR","id":"in_123"} (46 bytes) SHA-256 bb0978df8a882c2f1e8984afe7d9af069090f2bb14cf7478dc64735fad0b690d
Trailing zeros in numbers disappear, which is why prices are often sent as strings.
Input: RFC 8785 section 3.2.2 sample
Result: {"literals":[null,true,false],"numbers":[333333333.3333333,1e+30,4.5,0.002,1e-27],"string":"€$\u000f\nA'B\"\\\\\"/"}
Matches the bytes in section 3.2.4 of the RFC.
Input: {"id": 12345678901234567890, "id": 2}
Result: warn /id: 12345678901234567890 is larger than 2^53 and becomes 12345678901234567000... error /id: Duplicate property name "id". I-JSON forbids duplicates, so JCS can't canonicalize this object.
Not I-JSON, so there is no canonical form.

04Common use cases

  • Getting the exact bytes to sign or hash for a JSON payload
  • Debugging why two services compute different hashes for the same JSON object
  • Checking a JCS implementation in another language against known-good output
  • Finding duplicate keys or unsafe large integers before signing data
  • Creating test vectors for Data Integrity jcs proofs or signed webhooks

05Tips

  • Send integers above 9007199254740991 as strings; JCS can only represent IEEE 754 doubles
  • Hash the UTF-8 bytes of the canonical text, not a pretty-printed copy
  • Key order uses UTF-16 code units, so a plain byte sort in UTF-8 gives a different order for some non-ASCII keys
  • 1.0 and 1 are the same number in JCS, so both canonicalize to 1

06Related concepts

RFC 8785, JCS, canonical JSON, I-JSON, JSON signing, deterministic serialization.

Frequently Asked Questions

What is JSON Canonicalizer (JCS)?

JSON Canonicalizer (JCS) is a free, browser-based developer tool on AIDToolStack. Turn JSON into its RFC 8785 canonical form: sorted keys, no whitespace, ECMAScript number format. See the bytes and SHA-256, and catch duplicate keys. It requires no installation or sign-up and works entirely in your browser.

Is JSON Canonicalizer (JCS) free to use?

Yes. No sign-up, no fees and no usage cap.

Does JSON Canonicalizer (JCS) store my data?

No. It runs in your browser; nothing is uploaded.

Related Tools

Reviews and commentsShow

Reviews

Sign in to leave a review.

Loading reviews…

Comments

Sign in to leave a comment.

Loading comments…

What changed in AI dev tools, once a month

Renames, shutdowns, pricing changes and new MCP setups, each with a source.

Subscribe