AI-native JSON-LD schema utility with automated URL-to-Schema generation, intelligent content analysis, caching, rate limiting, performance monitoring, and AI optimization (ChatGPT, Voice). Complete automation & scale features. Zero runtime dependencies.
npm install ai-seo> Minimal AI-friendly JSON-LD schema utility for SEO. Zero dependencies.




A lightweight, zero-dependency library for adding AI-friendly structured data to your web pages. Works seamlessly across all JavaScript environments: Node.js, Bun, Deno, browsers, and edge runtimes.
- ๐ Zero dependencies - Ultra-lightweight
- ๐ง AI-optimized - Enhanced for LLM understanding
- ๐ Universal - Works in any JavaScript environment
- ๐ฏ Type-safe - Full TypeScript support
- ๐ง Framework helpers - Built-in Next.js, Nuxt.js support
- ๐ Schema builders - Product, Article, LocalBusiness, Event schemas
- ๐ Multiple schemas - Inject multiple schemas at once
- ๐ฅ๏ธ SSR/SSG ready - Server-side rendering utilities
- โ
Tested - Comprehensive test suite with Node.js test runner
- ๐ฆ Tree-shakable - Optimized for modern bundlers
- โก Schema Composer - Fluent API for building complex schemas
- ๐ญ Framework Integrations - React hooks, Vue composables, Svelte stores
- ๐ Industry Templates - Pre-built schemas for common use cases
- ๐ Enhanced Validation - Detailed error messages and quality scoring
- ๐ Analytics Integration - Track schema performance and effectiveness
- ๐ NEW: AI Search Engine Optimization - ChatGPT, Bard, Perplexity integration
- ๐ค NEW: Conversational Schema Structure - Optimized for AI-powered search
- ๐ NEW: Multi-Platform Deployment - WordPress, Shopify, Webflow, GTM integration
- ๐ฏ NEW: Interactive CLI - Guided schema creation with prompts
- ๐ฆ NEW: Bulk Operations - Enterprise-grade schema management
``bash`
npm install ai-seo
`javascript
import { addFAQ, initSEO } from 'ai-seo';
// Quick FAQ injection
addFAQ('What is ai-seo?', 'A minimal SEO utility for structured data');
// Custom schema injection
initSEO({
schema: {
"@context": "https://schema.org",
"@type": "Organization",
"name": "Your Company"
}
});
`
Build complex schemas with ease using our fluent API:
`javascript
import { product, article, organization } from 'ai-seo';
// Product schema with method chaining
const productSchema = product()
.name('Amazing Product')
.description('This product will change your life')
.image(['product1.jpg', 'product2.jpg'])
.brand('YourBrand')
.offers({ price: 99.99, priceCurrency: 'USD' })
.rating(4.8, 127)
.inject(); // Automatically injects into DOM
// Article schema
const blogPost = article()
.name('How to Use Schema Composer')
.author('Jane Doe')
.publisher('Tech Blog')
.datePublished('2024-01-15T10:00:00Z')
.keywords(['seo', 'schema', 'javascript'])
.build(); // Returns schema object
`
#### React Hooks
`jsx
import { Frameworks } from 'ai-seo';
function ProductPage({ product: productData }) {
// Hook automatically manages schema lifecycle
const { schema, cleanup } = Frameworks.React.useSEO(() =>
product()
.name(productData.name)
.brand(productData.brand)
.offers({ price: productData.price })
.build()
);
return
// Higher-order component
const WithSEO = Frameworks.React.withSEO(MyComponent, (props) =>
article().name(props.title).author(props.author).build()
);
`
#### Vue Composables
`vue`
#### Svelte Stores
`svelte`
Pre-built schemas for common industries:
`javascript
import { Templates } from 'ai-seo';
// E-commerce product page
const productSchema = Templates.ecommerce.productPage({
name: 'Wireless Headphones',
price: 199.99,
brand: 'AudioTech',
inStock: true,
rating: 4.5,
reviewCount: 234
});
// Restaurant listing
const restaurantSchema = Templates.restaurant.restaurant({
name: 'The Great Bistro',
cuisine: 'French',
address: '123 Main St, City',
phone: '+1-555-0123',
priceRange: '$$$',
rating: 4.7,
reviewCount: 89
});
// Real estate property
const propertySchema = Templates.realEstate.realEstateProperty({
title: 'Beautiful Family Home',
price: 450000,
bedrooms: 3,
bathrooms: 2,
squareFeet: 1800,
agent: { name: 'John Smith', phone: '+1-555-0456' }
});
// Blog post
const blogSchema = Templates.content.blogPost({
title: 'Ultimate SEO Guide',
author: 'Jane Doe',
publishDate: '2024-01-15T10:00:00Z',
tags: ['seo', 'marketing', 'web'],
wordCount: 2500
});
`
Intelligent schema caching with automatic optimization:
`javascript
import { Cache } from 'ai-seo';
// Configure intelligent caching
Cache.configure({
strategy: 'intelligent', // Auto-cache complex schemas
ttl: 3600000, // 1 hour cache lifetime
maxSize: 100, // Max cached schemas
enableCompression: true, // Compress cached data
enableMetrics: true // Track performance
});
// Get performance metrics
const metrics = Cache.getMetrics();
console.log(Cache hit rate: ${metrics.hitRate}%);Total schemas cached: ${metrics.cacheSize}
console.log();`
Load schemas only when needed for better performance:
`javascript
import { LazySchema } from 'ai-seo';
// Load when element becomes visible
const lazyProduct = new LazySchema('Product')
.loadWhen('visible')
.withData(() => ({
name: 'Premium Headphones',
price: 199.99,
inStock: true
}))
.configure({
rootMargin: '50px', // Load 50px before visible
threshold: 0.1 // Load when 10% visible
})
.inject();
// Load on user interaction
const lazyArticle = new LazySchema('Article')
.loadWhen('interaction')
.withData(() => getArticleData())
.inject();
// Custom loading condition
const lazyEvent = new LazySchema('Event')
.loadWhen('custom', () => shouldLoadEvent())
.withData(getEventData)
.inject();
`
Track and optimize schema performance:
`javascript
import { Performance } from 'ai-seo';
// Get comprehensive performance report
const report = Performance.getReport();
console.log('=== Performance Report ===');
console.log(Average injection time: ${report.averageInjectionTime.toFixed(2)}ms);Cache hit rate: ${report.cacheHitRate}%
console.log();Performance score: ${report.performanceScore}/100
console.log();Total schemas: ${report.totalSchemas}
console.log();
// Get actionable recommendations
report.recommendations.forEach(rec => {
console.log(${rec.severity.toUpperCase()}: ${rec.message});Action: ${rec.action}
console.log();
});
// Example output:
// MEDIUM: Many schemas detected. Consider lazy loading for better performance.
// Action: Use LazySchema for non-critical schemas: new LazySchema("Product").loadWhen("visible")
`
Get detailed feedback on your schemas:
`javascript
import { validateSchemaEnhanced, getSchemaSuggestions } from 'ai-seo';
const schema = product().name('Test Product').build();
const validation = validateSchemaEnhanced(schema, {
strict: true,
suggestions: true
});
console.log(Schema quality score: ${validation.score}/100);
console.log('Errors:', validation.errors);
console.log('Warnings:', validation.warnings);
console.log('Suggestions:', validation.suggestions);
// Get best practices for schema type
const tips = getSchemaSuggestions('Product');
console.log('Product schema tips:', tips);
`
Track schema performance and effectiveness:
`javascript
import { Analytics } from 'ai-seo';
// Track schema injections
const schema = product().name('Tracked Product').build();
initSEO({
schema,
analytics: (event) => {
console.log('Schema event:', event);
// Send to your analytics service
}
});
// Get performance metrics
const metrics = Analytics.getSchemaMetrics();
console.log(Total schemas: ${metrics.total_schemas});
console.log('Schema types:', metrics.schema_types);
// Export analytics data
const csvData = Analytics.exportAnalytics('csv');
const jsonData = Analytics.exportAnalytics('json');
`
Create rich, structured schemas with our helper functions:
#### Product Schema
`javascript
import { SchemaHelpers, initSEO } from 'ai-seo';
const productSchema = SchemaHelpers.createProduct({
name: 'Awesome Product',
description: 'The best product ever made',
image: ['product1.jpg', 'product2.jpg'],
brand: 'Your Brand',
offers: {
price: 99.99,
priceCurrency: 'USD',
availability: 'https://schema.org/InStock'
},
aggregateRating: {
ratingValue: 4.8,
reviewCount: 127
}
});
initSEO({ schema: productSchema });
`
#### Article Schema
`javascript`
const articleSchema = SchemaHelpers.createArticle({
headline: 'How to Use AI-SEO',
description: 'A comprehensive guide to structured data',
author: 'Jane Doe',
datePublished: '2024-01-15T10:00:00Z',
publisher: 'Tech Blog',
keywords: ['seo', 'structured-data', 'ai']
});
#### Local Business Schema
`javascript`
const businessSchema = SchemaHelpers.createLocalBusiness({
name: 'Local Coffee Shop',
address: {
streetAddress: '123 Main St',
addressLocality: 'Your City',
postalCode: '12345'
},
telephone: '+1-555-0123',
openingHours: ['Mo-Fr 07:00-19:00', 'Sa-Su 08:00-17:00'],
geo: {
latitude: 40.7128,
longitude: -74.0060
}
});
#### Event Schema
`javascript`
const eventSchema = SchemaHelpers.createEvent({
name: 'Web Development Conference',
startDate: '2024-06-15T09:00:00Z',
endDate: '2024-06-15T17:00:00Z',
location: {
name: 'Conference Center',
address: '456 Event Ave, Tech City'
},
organizer: 'Tech Events Inc'
});
Inject multiple schemas at once:
`javascript
import { injectMultipleSchemas, SchemaHelpers } from 'ai-seo';
const schemas = [
SchemaHelpers.createProduct({ name: 'Product 1' }),
SchemaHelpers.createArticle({ headline: 'Article 1' }),
SchemaHelpers.createLocalBusiness({ name: 'Business 1' })
];
const results = injectMultipleSchemas(schemas, {
debug: true,
validate: true
});
console.log(Successfully injected ${results.filter(r => r.success).length} schemas);`
Perfect for Next.js, Nuxt.js, and other SSR frameworks:
#### Next.js Integration
`javascript
// app/layout.js
import { SSR, organization } from 'ai-seo';
import Head from 'next/head';
export default function RootLayout({ children }) {
const schema = organization().name('Your Company').url('https://yoursite.com').build();
const { jsonLd, socialMeta } = SSR.frameworks.nextJS.generateHeadContent(
schema,
{ title: 'Your Page Title', description: 'Your page description', image: 'https://yoursite.com/og-image.jpg' }
);
return (