Local Business Schema Framework

Use conditional-logic schema generation to keep Local Business markup aligned with real page state and avoid stale or invalid static templates.

When To Use It

Google Search CentralLocal Business documentation

Use on the page for one physical business location, typed with the most specific LocalBusiness subtype and carrying the same name, address and hours users see.

Key Implementation Documentation Highlights

  • Required properties: name, address. address is a PostalAddress; include as many of streetAddress, addressLocality, addressRegion, postalCode and addressCountry (2-letter ISO 3166-1) as possible.
  • Recommended properties: url, telephone, geo, openingHoursSpecification, priceRange, menu, servesCuisine, department, aggregateRating, review. telephone is recommended, not required.
  • Use the most specific LocalBusiness subtype (for example Restaurant, DaySpa, HealthClub) rather than LocalBusiness itself.
  • telephone includes the country and area code; geo.latitude and geo.longitude carry at least 5 decimal places; url must be a working link; priceRange (for example $10-15 or $$$) must be under 100 characters or Google won't show it.
  • openingHoursSpecification: dayOfWeek plus opens and closes in hh:mm or hh:mm:ss. Open 24 hours is 00:00 to 23:59, closed all day is 00:00 to 00:00, hours past midnight are one entry with closes earlier than opens, and seasonal hours add validFrom and validThrough (YYYY-MM-DD).
  • department: a nested LocalBusiness per department, named "{store name} {department name}" unless the department name is explicitly branded.
  • aggregateRating and review are only for sites that capture reviews about other local businesses, following the Review snippet guidelines. Self-serving reviews of the business on its own site are not eligible for stars.
  • Restaurant carousel (limited): Google currently limits it to a small set of restaurant providers, who register interest through a Google form. It requires image (crawlable, 16x9, 4x3 or 1x1, at least 50,000 pixels) and name, recommends address and servesCuisine, and follows the Carousel guidelines (an ItemList on a summary page).
  • Google expects content parity: every marked-up value must match what users can see on the page.
  • Validate with the Rich Results Test and URL Inspection, then monitor the related Search Console report for errors and warnings after deployment.

Template Approach

const pageData = {
  name: "Moody Street Noodle Bar",
  url: "https://www.example.com/locations/waltham",
  telephone: "+1-781-555-0142",
  street: "212 Moody Street",
  city: "Waltham",
  region: "MA",
  postalCode: "02453"
};

const staticTemplate = {
  "@context": "https://schema.org",
  "@type": "Restaurant",
  "name": pageData.name,
  "url": pageData.url,
  "telephone": pageData.telephone,
  "address": {
    "@type": "PostalAddress",
    "streetAddress": pageData.street,
    "addressLocality": pageData.city,
    "addressRegion": pageData.region,
    "postalCode": pageData.postalCode,
    "addressCountry": "US"
  },
  "priceRange": "$$"
};

Conditional-logic Framework

const ISO_DATE_TIME = /^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2}))?(Z|[+-]\d{2}:\d{2})?)?$/;

function isAbsoluteUrl(value) {
  return typeof value === "string" && /^https?:\/\/[^\s/?#]+\.[^\s/?#]+(?:[/?#]\S*)?$/i.test(value);
}

// Returns the ISO 8601 string unchanged (timezone offset kept), or null if unparseable.
function toIsoDateTime(value) {
  if (typeof value !== "string") return null;
  const text = value.trim();
  const m = text.match(ISO_DATE_TIME);
  if (!m) return null;
  const [, y, mo, d, h = "00", mi = "00", s = "00"] = m;
  const date = new Date(Date.UTC(+y, +mo - 1, +d));
  if (date.getUTCMonth() !== +mo - 1 || date.getUTCDate() !== +d) return null;
  if (+h > 23 || +mi > 59 || +s > 59) return null;
  return text;
}

function toIsoDate(value) {
  const iso = toIsoDateTime(value);
  return iso ? iso.slice(0, 10) : null;
}

// Drops null, undefined, "", [] and {} recursively.
function compact(value) {
  if (Array.isArray(value)) {
    const items = value.map(compact).filter((v) => v !== undefined);
    return items.length ? items : undefined;
  }
  if (value && typeof value === "object") {
    const out = {};
    for (const [key, v] of Object.entries(value)) {
      const c = compact(v);
      if (c !== undefined) out[key] = c;
    }
    return Object.keys(out).length ? out : undefined;
  }
  return value === null || value === undefined || value === "" ? undefined : value;
}

function passesPageGates(source) {
  if (source.indexable === false) return false;
  if (source.canonicalUrl && source.url && source.canonicalUrl !== source.url) return false;
  return source.contentVisible !== false;
}


const LOCAL_BUSINESS_TYPES = {
  restaurant: "Restaurant",
  cafe: "CafeOrCoffeeShop",
  bakery: "Bakery",
  day_spa: "DaySpa",
  gym: "HealthClub",
  dentist: "Dentist",
  auto_repair: "AutoRepair",
  hardware_store: "HardwareStore"
};
const FOOD_TYPES = ["Restaurant", "CafeOrCoffeeShop", "Bakery"];
const DAYS = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
const TIME = /^([01]\d|2[0-3]):[0-5]\d(:[0-5]\d)?$/;

// Use the most specific LocalBusiness subtype available.
function chooseLocalBusinessType(source) {
  return LOCAL_BUSINESS_TYPES[source.category] || "LocalBusiness";
}

function hasFiveDecimals(value) {
  return typeof value === "number" && /^-?\d+\.\d{5,}$/.test(String(value));
}

function buildHours(spec) {
  const days = (spec.days || []).filter((d) => DAYS.includes(d));
  if (!days.length || !TIME.test(spec.opens || "") || !TIME.test(spec.closes || "")) return null;
  // 24 hours: 00:00 to 23:59. Closed all day: 00:00 to 00:00. Past midnight: closes earlier than opens.
  return {
    "@type": "OpeningHoursSpecification",
    dayOfWeek: days.map((d) => `https://schema.org/${d}`),
    opens: spec.opens,
    closes: spec.closes,
    validFrom: toIsoDate(spec.validFrom), // seasonal hours only
    validThrough: toIsoDate(spec.validThrough)
  };
}

function buildLocalBusinessSchema(source) {
  // (a) Page gates: indexable, self-canonical, business details visible on the page.
  if (!passesPageGates(source)) return null;

  // (b) Required: name, address.
  const address = source.address || {};
  if (!source.name || !address.street || !address.locality) return null;

  const type = chooseLocalBusinessType(source);
  const country = String(address.country || "").toUpperCase();
  const geo = source.geo || {};

  // (c) Required + recommended properties, only when the source has them.
  const schema = {
    "@context": "https://schema.org",
    "@type": type,
    "@id": isAbsoluteUrl(source.url) ? `${source.url}#business` : null,
    name: source.name,
    url: isAbsoluteUrl(source.url) ? source.url : null,
    image: (source.images || []).filter(isAbsoluteUrl),
    // (d) Custom rules: international phone, 5-decimal geo, hh:mm hours, short priceRange.
    telephone: /^\+\d/.test(source.telephone || "") ? source.telephone : null,
    address: {
      "@type": "PostalAddress",
      streetAddress: address.street,
      addressLocality: address.locality,
      addressRegion: address.region,
      postalCode: address.postalCode,
      addressCountry: /^[A-Z]{2}$/.test(country) ? country : null
    },
    geo: hasFiveDecimals(geo.latitude) && hasFiveDecimals(geo.longitude)
      ? { "@type": "GeoCoordinates", latitude: geo.latitude, longitude: geo.longitude }
      : null,
    openingHoursSpecification: (source.hours || []).map(buildHours),
    priceRange: source.priceRange && source.priceRange.length < 100 ? source.priceRange : null,
    menu: FOOD_TYPES.includes(type) && isAbsoluteUrl(source.menuUrl) ? source.menuUrl : null,
    servesCuisine: FOOD_TYPES.includes(type) ? source.cuisines : null,
    department: (source.departments || []).map((dept) => ({
      "@type": chooseLocalBusinessType(dept),
      // "{store name} {department name}" unless the department name is its own brand.
      name: dept.branded ? dept.name : `${source.name} ${dept.name}`,
      telephone: /^\+\d/.test(dept.telephone || "") ? dept.telephone : null,
      openingHoursSpecification: (dept.hours || []).map(buildHours)
    })),
    // Ratings only on sites that collect reviews about other businesses (no self-serving reviews).
    aggregateRating: source.reviewsAreAboutOtherBusinesses && source.rating ? {
      "@type": "AggregateRating",
      ratingValue: source.rating.value,
      reviewCount: source.rating.count
    } : null
  };

  // (e) Strip empty values.
  return compact(schema);
}

// Usage:
// const source = {
//   "url": "https://www.example.com/locations/waltham",
//   "canonicalUrl": "https://www.example.com/locations/waltham",
//   "indexable": true,
//   "contentVisible": true,
//   "category": "restaurant",
//   "name": "Moody Street Noodle Bar",
//   "images": [
//     "https://www.example.com/images/noodle-bar-16x9.jpg",
//     "https://www.example.com/images/noodle-bar-4x3.jpg",
//     "https://www.example.com/images/noodle-bar-1x1.jpg"
//   ],
//   "telephone": "+1-781-555-0142",
//   "address": {
//     "street": "212 Moody Street",
//     "locality": "Waltham",
//     "region": "MA",
//     "postalCode": "02453",
//     "country": "US"
//   },
//   "geo": {
//     "latitude": 42.37241,
//     "longitude": -71.23683
//   },
//   "hours": [
//     {
//       "days": [
//         "Monday",
//         "Tuesday",
//         "Wednesday",
//         "Thursday"
//       ],
//       "opens": "11:30",
//       "closes": "21:30"
//     },
//     {
//       "days": [
//         "Friday",
//         "Saturday"
//       ],
//       "opens": "11:30",
//       "closes": "01:00"
//     },
//     {
//       "days": [
//         "Sunday"
//       ],
//       "opens": "00:00",
//       "closes": "00:00"
//     }
//   ],
//   "priceRange": "$$",
//   "menuUrl": "https://www.example.com/locations/waltham/menu",
//   "cuisines": [
//     "Japanese",
//     "Ramen"
//   ],
//   "reviewsAreAboutOtherBusinesses": false
// };
// const schema = buildLocalBusinessSchema(source); // null when a gate or required property fails

The Output As An Entity Graph

The conditional-logic output above, parsed in your browser and drawn as the graph a crawler builds from it. Every nested object is a node and the property that holds it is the edge. Tap a node to inspect its properties, or drag to rearrange.

Why Conditional Logic Is Better Than Static Templates

  • Prevents emitting empty, null, or stale fields that frequently trigger rich result warnings.
  • Supports multiple page states (for example: no rating yet, no image yet, no offers yet) without duplicate templates.
  • Lets engineering teams centralize schema policy checks and validation in reusable code paths.
  • Makes large-scale schema maintenance safer when content models evolve over time.

Property Reference

What Google's Local business documentation requires and recommends, property by property. These are the same rules the SchemaCDN validator checks. Each name links to its schema.org definition.

Local business properties in Google's documentation
PropertyGoogleExpectsNotes
addressRequiredPostalAddressThe physical location of the business. Include as many properties as possible.
address.streetAddressRecommendedTextThe street address.
address.addressLocalityRecommendedTextThe city or locality.
address.addressRegionRecommendedTextThe region, state or province.
address.postalCodeRecommendedTextThe postal code.
address.addressCountryRecommendedText or CountryThe country, as a two-letter ISO 3166-1 alpha-2 code.
nameRequiredTextThe name of the business.
aggregateRatingRecommendedAggregateRatingThe average rating of the local business based on multiple ratings or reviews.
departmentRecommendedLocalBusiness, can repeatA nested item for a single department.
geoRecommendedGeoCoordinatesGeographic coordinates of the business.
geo.latitudeRecommendedNumberThe latitude of the business location, with at least 5 decimal places.
geo.longitudeRecommendedNumberThe longitude of the business location, with at least 5 decimal places.
menuRecommendedURLThe fully-qualified URL of the menu.
openingHoursSpecificationRecommendedOpeningHoursSpecification, can repeatHours during which the business location is open.
openingHoursSpecification.closesRecommendedTimeThe time the business location closes, in hh:mm:ss format.
openingHoursSpecification.dayOfWeekRecommendedEnum, can repeatOne or more of Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday. One of: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, and 1 more.
openingHoursSpecification.opensRecommendedTimeThe time the business location opens, in hh:mm:ss format.
openingHoursSpecification.validFromRecommendedDateThe start date of a seasonal business closure, in YYYY-MM-DD format.
openingHoursSpecification.validThroughRecommendedDateThe end date of a seasonal business closure, in YYYY-MM-DD format.
priceRangeRecommendedTextThe relative price range of the business; must be shorter than 100 characters.
reviewRecommendedReview, can repeatA review of the local business.
servesCuisineRecommendedText, can repeatThe type of cuisine the restaurant serves.
telephoneRecommendedTextA business phone number meant to be the primary contact method for customers; include country and area code.
urlRecommendedURLThe fully-qualified URL of the specific business location.

Explore Other Schema Framework Pages

Loyalty Program Use to publish a loyalty program and its tiers once at the organization level, so member prices and member shipping can reference them. MemberProgram Open Math Solvers Use for pages that solve mathematical expressions and present step-by-step computational guidance. MathSolver Open Merchant Listing Use on pages where a product can be bought, with price, availability, shipping and return details. Product Open Limited Movie Use for movie detail pages with canonical film information and transparent metadata attribution. Movie Open Organization Use for official organization pages to clarify brand identity and authoritative entity signals. Organization Open Retired Practice Problems Use for educational practice content that presents solvable problems and answer validation structure. Quiz Open Product Snippet Use for product pages where pricing, availability, and product identity are visible to users. Product Open Product Variants Use when one product comes in variants such as size or color, grouped with ProductGroup. ProductGroup Open Profile Page Use for creator or contributor profile pages where identity attributes and ownership are explicit. ProfilePage Open Q&A Use for pages where users submit questions and community or editorial answers are displayed. QAPage Open Recipe Use for recipe pages with complete ingredients, instructions, and preparation details. Recipe Open Return Policy Use to publish a merchant return policy once at the organization level, with offer-level overrides. MerchantReturnPolicy Open Review Snippet Use when a page publishes genuine reviews tied to a clearly identified product, service, or entity. Review Open Shipping Policy Use to publish shipping rates, delivery times and destinations once at the organization level. ShippingService Open Site Name Use on the home page so Google shows the preferred site name in search results. WebSite Open Retired Sitelinks Search Box Use on sites with a functioning internal search endpoint that can accept URL query parameters. WebSite Open Software App (Beta) Use for software product pages that describe platform support and application category clearly. SoftwareApplication Open Limited Speakable Use for news-style pages where specific text segments are appropriate for text-to-speech playback. SpeakableSpecification Open Subscription and Paywalled Content Use for pages with restricted sections so Google can distinguish free previews from protected content. CreativeWork Open Limited Vacation Rental Use for rental property detail pages where booking-relevant amenities and location signals are explicit. VacationRental Open Retired Vehicle Listing Use for inventory pages selling vehicles with standardized listing fields and offer information. Car Open Video Use for pages where a primary video is embedded and key media metadata is visible on-page. VideoObject Open Article Use for editorial pages where the visible content is a complete article with a clear byline and publication timestamps. Article Open Limited Book Actions Use when your page helps users read, preview, or purchase books through clearly described actions. Book Open Breadcrumb Use on pages that belong to a clear hierarchy and display navigational trail links users can follow. BreadcrumbList Open Carousel Use when a page lists multiple related entities in a scannable sequence that can be surfaced as cards. ItemList Open Course Use for educational offerings where curriculum details, provider identity, and delivery context are explicit. Course Open Dataset Use for dataset landing pages so datasets are discoverable in Google Dataset Search with license, creator and download details. Dataset Open Discussion Forum Use for forum and community threads where a primary post and subsequent replies are publicly visible. DiscussionForumPosting Open Limited Education Q&A Use for educational question-answer pages where a single canonical answer and supporting context are visible. Quiz Open Employer Aggregate Rating Use on pages that publish employer rating aggregates from a clear and policy-compliant review source. EmployerAggregateRating Open Retired Estimated Salary Use for compensation insight pages that present transparent salary ranges for specific occupations and locations. Occupation Open Event Use for upcoming events with a real-world or virtual occurrence, schedule, and location context. Event Open Retired Fact Check Use for fact-checking pages that evaluate a specific claim with a transparent rating methodology. ClaimReview Open Retired Home Activities Use for virtual classes and activities where participation details and timing are clearly listed. Event Open Retired How-To Use for instructional content that teaches a process through ordered steps and actionable detail. HowTo Open Image Metadata Use on image pages and image hosts that expose ownership and licensing information to search engines. ImageObject Open Job Posting Use for active job listings that include role details, hiring entity, and location/salary context. JobPosting Open Retired Learning Video Use for educational videos where the learning objective and pedagogical structure are explicit. LearningResource Open

Implement Local Business Schema Frameworks Correctly

Get implementation support for conditional schema architecture, validation, and deployment governance.