Pular para o conteúdo

Caps. 7/18 · Ferramenta

Gerador de Schema.org LocalBusiness

Preencha os campos e copie o JSON-LD pronto para colar no <head> da sua página. Sem cadastro, sem pedágio — a ferramenta roda aqui mesmo.

Ferramenta ao vivo

Preencha e copie

O JSON-LD ao lado se atualiza a cada campo. Só nome e URL são obrigatórios.

Ir para o JSON-LD gerado
Negócio
Endereço
Coordenadas
Atuação e presença
Áreas atendidas
Perfis (sameAs)
Serviços

JSON-LD gerado

Faltam campos obrigatórios
application/ld+json
{
"@context": "https://schema.org",
"@type": "LocalBusiness",
"address": {
"@type": "PostalAddress"
}
}

Falta ou está inválido: Nome do negócio, URL do site.

Código-fonte

Código do gerador

A mesma função que roda acima — baixe e use no seu build.

schema-generator.js
// schema-generator.js
// Pure, framework-agnostic builder for Schema.org LocalBusiness JSON-LD.
// Same function powers the live tool at eduardomendes.com.br/repo/schema and
// this downloadable module — no divergence.
//
// Usage:
// import { buildSchema } from "./schema-generator.js";
// const jsonld = buildSchema({ type: "Dentist", name: "...", ... });
// console.log(JSON.stringify(jsonld, null, 2));
/** Specific @type values that all inherit from LocalBusiness. */
export const BUSINESS_TYPES = [
"LocalBusiness",
"Dentist",
"LegalService",
"Restaurant",
"HomeAndConstructionBusiness",
];
/** Drop empty strings / empty arrays so the output stays clean. */
function clean(value) {
if (Array.isArray(value)) {
const arr = value.map(clean).filter((v) => v !== undefined && v !== "" && !(Array.isArray(v) && v.length === 0));
return arr.length ? arr : undefined;
}
if (value && typeof value === "object") {
const out = {};
for (const [k, v] of Object.entries(value)) {
const c = clean(v);
if (c !== undefined && c !== "") out[k] = c;
}
return Object.keys(out).length ? out : undefined;
}
if (typeof value === "string") return value.trim() || undefined;
return value;
}
/**
* @param {object} data
* @param {string} data.type One of BUSINESS_TYPES
* @param {string} data.name Business name (required)
* @param {string} [data.description]
* @param {string} [data.url]
* @param {string} [data.telephone]
* @param {string} [data.priceRange]
* @param {object} [data.address] { street, locality, region, postalCode, country }
* @param {object} [data.geo] { lat, lng }
* @param {string[]} [data.areaServed]
* @param {string[]} [data.sameAs]
* @param {string[]} [data.services] Service names offered
* @returns {object} JSON-LD object
*/
export function buildSchema(data = {}) {
const type = BUSINESS_TYPES.includes(data.type) ? data.type : "LocalBusiness";
const address = data.address
? {
"@type": "PostalAddress",
streetAddress: data.address.street,
addressLocality: data.address.locality,
addressRegion: data.address.region,
postalCode: data.address.postalCode,
addressCountry: data.address.country,
}
: undefined;
const geo =
data.geo && (data.geo.lat || data.geo.lng)
? { "@type": "GeoCoordinates", latitude: data.geo.lat, longitude: data.geo.lng }
: undefined;
const services = Array.isArray(data.services)
? data.services
.map((s) => (typeof s === "string" ? s.trim() : ""))
.filter(Boolean)
.map((name) => ({ "@type": "Offer", itemOffered: { "@type": "Service", name } }))
: undefined;
const schema = {
"@context": "https://schema.org",
"@type": type,
name: data.name,
description: data.description,
url: data.url,
telephone: data.telephone,
priceRange: data.priceRange,
address,
geo,
areaServed: Array.isArray(data.areaServed)
? data.areaServed.map((a) => (typeof a === "string" ? a.trim() : "")).filter(Boolean)
: undefined,
sameAs: Array.isArray(data.sameAs)
? data.sameAs.map((s) => (typeof s === "string" ? s.trim() : "")).filter(Boolean)
: undefined,
makesOffer: services,
};
return clean(schema) || { "@context": "https://schema.org", "@type": type };
}
/** Which fields are required for a valid, useful result. */
export function validate(data = {}) {
const errors = {};
if (!data.name || !data.name.trim()) errors.name = "required";
if (!data.url || !data.url.trim()) errors.url = "required";
if (data.url && data.url.trim() && !/^https?:\/\//i.test(data.url.trim())) errors.url = "must start with http(s)://";
return errors;
}

Dúvidas

Perguntas frequentes

Onde eu coloco o código gerado?

Dentro de uma tag <script type="application/ld+json"> no <head> (ou no fim do <body>) da página que descreve o negócio.

Qual @type devo escolher?

Use o mais específico que descreve você: Dentist, LegalService, Restaurant ou HomeAndConstructionBusiness. Todos herdam de LocalBusiness, então na dúvida use LocalBusiness.

Isso garante rich results no Google?

Não há garantia — o schema torna a página elegível. Valide sempre no Rich Results Test e mantenha os dados consistentes com o que aparece na página.

Implementação

Prefere que eu implemente?

Conte o seu caso numa conversa e a gente define o escopo juntos.

Agendar conversa