Registry / testing / structured-data-testing-tool

structured-data-testing-tool

JSON →
library4.5.0jsnpmunverified

SDTT v4.5.0 is a library and CLI tool for inspecting and testing structured data on web pages, supporting JSON-LD, Microdata, and RDFa. It automatically detects Schema.org schemas in HTML or JSON sources, and includes built-in presets for Google, Twitter, Facebook, and social media meta tags. Users can create custom presets or schemas, and integrate with any test framework. The tool can accept URLs, files, strings, buffers, or streams, and output results to JSON. It is designed for ad-hoc testing or integration into CI/CD pipelines. Released under MIT license, it is actively maintained on GitHub.

npm install structured-data-testing-tool
INSTALL
IMPORT
SIG · STRUCTURED-DATA-TE
S
structured-data-testing-tool
testingjavascriptv4.5.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SDTT
✓ import { SDTT } from 'structured-data-testing-tool'
✗ const SDTT = require('structured-data-testing-tool').SDTT
SDTT is a named export, not default. ESM import preferred.
structuredDataTest
✓ import { structuredDataTest } from 'structured-data-testing-tool'
✗ import structuredDataTest from 'structured-data-testing-tool'
Common mistake: using default import. This is a named export.
Presets
✓ import { Presets } from 'structured-data-testing-tool'
Use Presets to list built-in presets. Requires ESM.
validate
✓ import { validate } from 'structured-data-testing-tool'
Low-level validation function for custom schemas.

Perform a structured data test on a URL against Twitter/Facebook presets and Article schema.

import { structuredDataTest } from 'structured-data-testing-tool'; async function runTest() { const result = await structuredDataTest('https://example.com/article', { presets: ['Twitter', 'Facebook'], schemas: ['Article'] }); console.log('Tests passed:', result.passed); console.log('Errors:', result.errors); } runTest().catch(console.error);
Debug
Known issues
breakingv4.0.0 changed the API from callback-based to async/await. All methods now return Promises.
fix
Update code to use async/await or .then() with the new Promise-based API.
affects: <4.0.0
deprecatedPresets.SocialMedia is deprecated and will be removed in v5. Use presets: ['Twitter', 'Facebook'] instead.
fix
Replace Presets.SocialMedia with explicit individual presets.
affects: >=4.0.0
gotchaWhen using the CLI, the --presets and --schemas flags accept comma-separated lists without spaces (--presets Twitter,Facebook). Including spaces (e.g., --presets Twitter, Facebook) causes parsing errors.
fix
Use --presets 'Twitter,Facebook' or supply multiple flags: -p Twitter -p Facebook.
affects: *
deprecatedThe --output flag writes a JSON file with the full result object. In v4.5.0, the output format changed to include nested results; old parsers expecting the flat format may break.
fix
Update any scripts that parse the output file to handle the new nested format.
affects: <4.5.0
gotchaThe library uses cheerio by default for HTML parsing. If testing pages with client-side-rendered content (e.g., React, Angular), structured data may not be found unless you provide a headless browser result.
fix
Pass the full rendered HTML (e.g., from Puppeteer) as a string or buffer instead of URL.
affects: *
breakingImport paths changed in v3.0.0: require('structured-data-testing-tool') no longer works. Must use destructured imports like { structuredDataTest }.
fix
Update imports from const SDTT = require(...) to import { structuredDataTest } from '...'.
affects: <3.0.0
Errors
Common errors & fixes
TypeError: structuredDataTest is not a function
Using default import instead of named import: import structuredDataTest from 'structured-data-testing-tool'
fix
Use named import: import { structuredDataTest } from 'structured-data-testing-tool'
Error: Cannot find module 'structured-data-testing-tool'
Package not installed or missing from node_modules
fix
Run npm install structured-data-testing-tool
SyntaxError: Unexpected token '??'
Node.js version is too old to support nullish coalescing operator used by the library (requires Node >= 14)
fix
Upgrade Node.js to version 14 or higher
Error: Request failed with status 403
The target URL is blocking automated requests (e.g., bot detection)
fix
Use the --file option with locally saved HTML or pass a headless browser response instead
Upgrade
Version history
4.5.0latest on npm
Audit
Dependencies
cheeriorequiredHTML parsing and traversal for extracting structured data from web pages
jsdomoptionalDOM implementation for parsing HTML documents, required for RDFa support
commanderrequiredCLI argument parsing for the command line interface
Agent activity
46 hits · last 30 days
node
42
Amazon
1
Resources
structured-data-testing-tool — npm install structured-data-testing-tool · libregistry