Validate a built page’s canonical URL and title against its Open Graph and X (Twitter card) metadata, then compare the declared preview image dimensions with a local PNG. Duplicate fields, malformed URLs, missing image descriptions and identity mismatches are reported. This is an offline, read-only, zero-dependency Node.js 22+ check, not a prediction of social-platform rendering.
This walkthrough uses the tool's public README and checked-in example files. Run the command from a repository checkout with Node.js 22+.
Run the checked-in example
node bin/open-graph-preview-validator.mjs --root examples --page pass.html
node bin/open-graph-preview-validator.mjs --root examples --page fail.html
npm run checkRead the result
The first example exits 0. The second exits 1 because OG and X image URLs disagree. Unreadable, out-of-root or unsupported local image evidence exits 2 as incomplete; it is never treated as a good preview. src/index.mjs exports TOOLID and validatePreview. See rules and limits.