Dev.to WebDev 🛠 Dev 👁 0 📖 4 min read

How to write Organization and Service JSON-LD for a local business (copy-paste template)

A local business page needs one business node and one node per service, linked by an @id. This post gives a copy-paste JSON-LD graph for both, and a Python script that checks it, for a made-up plumber. Usman Ishaq is a

A local business page needs one business node and one node per service, linked by an @id. This post gives a copy-paste JSON-LD graph for both, and a Python script that checks it, for a made-up plumber.

Usman Ishaq is a semantic SEO strategist and consultant, and the founder of Digital Vikingz. Schema should be written from the visible page outward, because Google's guidelines say not to mark up content the page does not show.

Which types does the template use?

In schema.org, Plumber is a subtype of HomeAndConstructionBusiness, which is a subtype of LocalBusiness. LocalBusiness is itself a subtype of Organization, so one node describes the business as both. Service is "a service provided by an organization", so each service gets its own node with a provider pointing back at the business.

Google's search gallery lists "Local business" and "Organization" features. No Service feature is listed there as of 4 December 2026, so treat Service as a description of the page's subject, not a route to a rich result.

The template

{
  "@context": "https://schema.org",
  "@graph": [
    {
      "@type": "Plumber",
      "@id": "https://www.example-plumbing.test/#business",
      "name": "Riverbend Plumbing",
      "url": "https://www.example-plumbing.test/",
      "telephone": "+1-512-555-0100",
      "address": {
        "@type": "PostalAddress",
        "streetAddress": "100 Example Street",
        "addressLocality": "Austin",
        "addressRegion": "TX",
        "postalCode": "78701",
        "addressCountry": "US"
      },
      "areaServed": [
        {
          "@type": "City",
          "name": "Austin"
        },
        {
          "@type": "City",
          "name": "Round Rock"
        }
      ]
    },
    {
      "@type": "Service",
      "@id": "https://www.example-plumbing.test/water-heater-repair/#service",
      "name": "Water heater repair",
      "serviceType": "Water heater repair",
      "url": "https://www.example-plumbing.test/water-heater-repair/",
      "provider": {
        "@id": "https://www.example-plumbing.test/#business"
      },
      "areaServed": {
        "@type": "City",
        "name": "Austin"
      }
    }
  ]
}

Replace Plumber with your own subtype and keep the @id values stable.

Which properties matter?

Property Node Rule Source
name, address Business Required by Google for LocalBusiness; address is a PostalAddress Google LocalBusiness docs
telephone, url Business Recommended by Google Google LocalBusiness docs
provider Service The service provider or performer schema.org/provider
areaServed Service, Business Geographic area where a service is provided schema.org/areaServed
serviceType Service The type of service offered schema.org/serviceType

Only the first row is required by Google (documentation read 4 December 2026).

How do you keep the markup honest?

Google's structured data guidelines say not to mark up content readers cannot see. The business name, phone number and service must therefore appear in the page text, and the script below checks for that.

A check script

It uses only the Python standard library. It pulls every JSON-LD block from an HTML file and checks that the JSON parses, each Service provider @id exists in the graph, the business has name and address, and its name and phone number appear in the visible text.

import json
import re
import sys
from html.parser import HTMLParser

LOCAL = {"LocalBusiness", "Plumber"}  # add your own subtype


class Page(HTMLParser):
    def __init__(self):
        super().__init__()
        self.ld, self.text, self.mode = [], [], None

    def handle_starttag(self, tag, attrs):
        if tag == "script":
            self.mode = "ld" if ("type", "application/ld+json") in attrs else "skip"
            self.ld += [""] * (self.mode == "ld")

    def handle_endtag(self, tag):
        self.mode = None if tag == "script" else self.mode

    def handle_data(self, data):
        if self.mode == "ld":
            self.ld[-1] += data
        elif self.mode is None:
            self.text.append(data)


def kinds(node):
    t = node.get("@type", [])
    return set(t if isinstance(t, list) else [t])


page = Page()
page.feed(open(sys.argv[1], encoding="utf-8").read())
visible = " ".join(page.text)
nodes = [n for block in page.ld for n in json.loads(block).get("@graph", [])]
ids = {n.get("@id") for n in nodes}
problems = []
for n in nodes:
    label = n.get("name", "?")
    if "Service" in kinds(n) and n.get("provider", {}).get("@id") not in ids:
        problems.append(f"{label}: provider does not point to a node in this graph")
    if kinds(n) & LOCAL:
        problems += [f"{label}: missing {p}" for p in ("name", "address") if not n.get(p)]
        if n.get("name", "") not in visible:
            problems.append(f"{label}: name is not in the visible text")
        phone = re.sub(r"\D", "", n.get("telephone", ""))
        if phone and phone not in re.sub(r"\D", "", visible):
            problems.append(f"{label}: telephone is not in the visible text")
print(f"{len(nodes)} nodes")
print("\n".join(problems) or "OK")
sys.exit(bool(problems))

Save a page containing the template as page.html and run python3 check_jsonld.py page.html. The script was tested on Python 3.9 with two files. A page holding the template, with the name and phone in the body, printed this:

2 nodes
OK

A copy with a mistyped provider @id and no phone in the body printed this and exited with status 1:

2 nodes
Riverbend Plumbing: telephone is not in the visible text
Water heater repair: provider does not point to a node in this graph

What does the script not do?

It does not check schema.org vocabulary or rich result eligibility. Use Google's Rich Results Test for that.

See also the earlier post on a connected JSON-LD graph for a person and company. If you want schema planned together with the pages it describes, see the technical SEO and schema service at usmanishaq.com.

Usman Ishaq is a semantic SEO strategist and consultant, and the founder of Digital Vikingz. He plans websites around entities, attributes and values, then builds topical maps, briefs, pages, internal links and schema so businesses rank in Google and get named by ChatGPT, Gemini and Perplexity.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.