Your first schema with Core
Core produces the JSON-LD payload. Your application remains responsible for placing it inside the final HTML document.
Before you start
Section titled “Before you start”You need Node.js 22.12 or newer and a TypeScript project.
1. Install
Section titled “1. Install”pnpm add @unschema-graph/core zodUsing npm, yarn, or bun? See all installation commands.
2. Build and serialize an Article
Section titled “2. Build and serialize an Article”import { Article, buildJsonLdGraph, serializeJsonLd } from '@unschema-graph/core';
const article = Article({ headline: 'My first framework-neutral JSON-LD', image: 'https://example.com/cover.jpg', datePublished: '2026-09-29', author: 'Ada Lovelace',});
const payload = buildJsonLdGraph([article], { graph: false });const jsonLd = serializeJsonLd(payload, { pretty: true });Article() validates the input. buildJsonLdGraph() adds the Schema.org context, and
serializeJsonLd() escapes characters that could terminate an HTML script element.
3. Check the output
Section titled “3. Check the output”jsonLd contains:
{ "@context": "https://schema.org", "@type": "Article", "headline": "My first framework-neutral JSON-LD"}The actual payload also contains the image, publication date, and author. Insert the
serialized string as the text content of one <script type="application/ld+json">
element using your framework’s server-rendering API.
4. Grow into a page graph
Section titled “4. Grow into a page graph”Build Organization, WebSite, and WebPage alongside the article, give shared nodes
stable @id values, and call buildJsonLdGraph(items, { baseUrl }) with the complete
array.
Next step
Section titled “Next step”Learn what builders, entities, identities, and graphs mean, or open the complete Core reference.