Open source · SEO & Search

Open Graph Preview Validator

Validate Open Graph and X card fields against the page identity.

v1.0.0 · Node.js 22+ · MIT

Browse the public repository · View releases

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 check

Read 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.