A flexible, reusable JavaScript module for automatically generating and injecting JSON-LD structured data into websites. Perfect for improving SEO and enabling rich results in search engines.
- Features
- Installation
- Quick Start
- Supported Schema Types
- Browser Support
- Documentation
- Examples
- License
- Configuration-driven - Simple setup with flexible configuration
- Multiple schema types - Restaurant, Product, Event, LocalBusiness, Organization, Article, Menu
- Dynamic DOM parsing - Extract data from HTML elements automatically
- Auto-injection - Automatic injection on page load or custom triggers
- Manual control - Full programmatic control when needed
- Event-driven - Inject after delays, after elements load, or on demand
- Debugging - Built-in logging for troubleshooting
- No dependencies - Pure vanilla JavaScript
Simply include the module in your HTML:
<script src="path/to/dynamic-jsonld-module.js"></script>No npm installation required - it's a standalone module!
const jsonld = new DynamicJSONLD({
autoInject: true,
pageIndicator: "data-page",
debug: true, // Set to false in production
});jsonld.registerSchema("restaurant", () =>
JSONLDSchemas.restaurant({
name: "My Restaurant",
telephone: "+1-555-1234",
url: "https://myrestaurant.com",
address: {
street: "123 Main St",
city: "Anytown",
region: "CA",
zip: "12345",
country: "US",
},
cuisines: ["Italian", "Mediterranean"],
hours: ["Mo-Fr 11:00-22:00", "Sa-Su 10:00-23:00"],
})
);Auto-inject on page load:
<body data-page="restaurant">
<!-- Content -->
</body>Manual injection:
const schema = jsonld.generate("restaurant");
jsonld.inject(schema);For comprehensive documentation, examples, and API reference, see:
- Complete Guide - Detailed documentation with examples
- API Reference - All methods and configuration options
- Real-world Examples - Restaurant, e-commerce, events, and more
| Schema Type | Use Case | Documentation |
|---|---|---|
| Restaurant/Café | Food & beverage establishments | See Guide |
| Product | E-commerce items | See Guide |
| Event | Conferences, concerts, webinars | See Guide |
| LocalBusiness | Service businesses | See Guide |
| Organization | Companies & nonprofits | See Guide |
| Article | Blog posts & news | See Guide |
| Menu | Restaurant menus | See Guide |
| Review | Customer reviews & ratings | See Guide |
| Browser | Minimum Version |
|---|---|
| Chrome | 60+ |
| Firefox | 55+ |
| Safari | 12+ |
| Edge | 79+ |
| Node.js | All versions (for server-side use) |
- DYNAMIC-JSONLD-GUIDE.md - Complete guide with examples
- CHANGELOG.md - Version history and updates
- LICENSE - MIT License details
See the DYNAMIC-JSONLD-GUIDE.md for:
- Real-world implementation examples
- Restaurant with dynamic menu parsing
- E-commerce product pages
- Event pages with structured data
- Complete API reference
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Submit a pull request
If you find this project helpful:
- ⭐ Star the repository
- 🐛 Report issues on GitHub
- 💬 Share with others
- Schema.org community
- Google Structured Data team
- Web developers who provided feedback
Version: v1.0.0 - November 2025
Last Updated: November 4, 2025
Created for: Web developers looking to improve SEO with structured data