JSON Canonicalizer

Canonicalize JSON per RFC 8785 — sort keys lexicographically and remove whitespace. Compute SHA-256 hash for digital signatures and payload verification.

Input JSON
Canonical Output

Features

📐 RFC 8785 Compliant

  • Recursive key sorting (lexicographic)
  • Whitespace removal
  • Deterministic output
  • Handles nested objects and arrays

🔐 SHA-256 Hash

  • Web Crypto API (native browser)
  • Hex-encoded digest output
  • Suitable for payload signing
  • Repeatable across platforms

🔍 Key Sort Diff

  • Shows keys that were reordered
  • Count of total keys processed
  • Detects already-sorted payloads
  • Useful for debugging JWS/JWK

RFC 8785 Guide

What is JSON Canonicalization?

RFC 8785 (JSON Canonicalization Scheme, JCS) defines a deterministic serialization format for JSON. It enables consistent hashing and signing of JSON payloads regardless of how the original JSON was formatted.

// Input (any order, any whitespace)
{
  "zebra": "last",
  "apple": "first"
}

// Canonical form (RFC 8785)
{"apple":"first","zebra":"last"}