To know exactly how to add review schema markup to HTML, you must generate a block of structured data code—preferably in JSON-LD format—and paste it into the <head> or <body> of your webpage. This code translates your visible customer reviews into a standardized format that search engines understand. By doing this, you allow search engines to extract your ratings and display gold star rich snippets directly under your links in the search results.
Key Takeaways
- JSON-LD is Google's recommended format for schema markup because it is isolated from your visible HTML structure.
- You cannot use review schema to display self-serving reviews on your own LocalBusiness or Organization homepage.
- Review schema requires specific properties like the reviewer's name, the item reviewed, and a valid rating value.
- Adding structured data directly helps AI search engines like Perplexity and ChatGPT extract and cite your business ratings.
- Always test your review schema using Google's Rich Results Test before publishing the code to your live website.
Adding this markup is a fundamental part of technical SEO. It does not just make your search results look better; it actively drives higher click-through rates. In this guide, we will break down the exact code you need, where to put it, and the strict rules you must follow to avoid Google penalties.
Why Learning How to Add Review Schema Markup to HTML Matters
Search engine results pages (SERPs) are incredibly crowded. You are competing against paid ads, local map packs, AI overviews, and ten other organic links. Standing out is no longer optional.
When you add review schema markup to your HTML, you give your search result a visual advantage. A standard search result contains a blue link and a short text description. A rich snippet result contains the blue link, the description, and a bright row of gold stars, alongside the total number of reviews and the average rating.
Data consistently shows that pages with star ratings get significantly higher click-through rates (CTR). A search result sitting in the number three spot with gold stars will frequently steal clicks from the number two or number one spot that lacks them. This happens because the stars instantly communicate trust and social proof before the user even visits your site.
Beyond traditional Google searches, structured data is vital for artificial intelligence. Large language models (LLMs) and AI search engines rely heavily on clean code to pull facts about your business. When users ask ChatGPT or Perplexity, "Who is the highest-rated service provider near me?", the AI scans the web. If your site uses clean JSON-LD schema, the AI can parse your ratings in milliseconds. If your site relies on messy, unstructured HTML tables, the AI will likely skip you. Learning how to rank on Perplexity for local searches starts with giving the AI data it can easily read.
Google's Strict Guidelines for Review Snippets
Before you write a single line of code, you must understand Google's rules. Search engines are highly protective of review snippets because fake reviews ruin the user experience. If you try to manipulate review schema, Google will issue a manual action penalty, removing your site from rich results entirely.
In 2019, Google updated its guidelines to ban "self-serving" reviews. You cannot add review schema to your own website's homepage to mark up your own LocalBusiness or Organization entity using reviews you collected yourself. If you own a plumbing company, you cannot put five-star schema on your homepage that says "Our plumbing company is rated 5 stars."
So, how do local businesses use review schema?
You can mark up specific products, specific services, or distinct events. For example, if you run a restaurant, you cannot put review schema on your main homepage. However, if you are learning how to market private event space for restaurants, you can absolutely add review schema to your dedicated "Private Dining Room" landing page, provided the reviews are specifically about that room and are visible on the page.
According to Google Search Central's Review Snippet Guidelines, you must also ensure:
- The reviews are visible to the user on the page.
- The markup refers to a specific product or service, not a general category.
- The reviews are written by actual customers, not your staff.
JSON-LD vs. Microdata: Choosing Your Format
There are three ways to write schema markup: JSON-LD, Microdata, and RDFa. Today, the choice is simple: you should always use JSON-LD.
Microdata and RDFa require you to wrap your visible HTML text in specific schema tags. This is dangerous because anytime you redesign your website or change a sentence, you risk breaking your schema code. JSON-LD, on the other hand, is a self-contained block of Javascript that sits hidden in the background of your page. It is completely isolated from your site's visual design.
Here is a clear look at why JSON-LD is the undisputed industry standard:
| Feature | JSON-LD (Recommended) | Microdata (Outdated) |
| Google Preference | Explicitly recommended by Google | Supported, but not preferred |
| Code Placement | Clean script tag in <head> or <body> | Intertwined with visible HTML tags |
| Maintenance | Very easy to update without breaking layout | High risk of breaking design during updates |
| Dynamic Injection | Can be deployed via Google Tag Manager | Must be hard-coded into page templates |
We will exclusively use JSON-LD for the remainder of this guide, as it is the most reliable method for how to add review schema markup to HTML.
The Anatomy of Review Schema Code (With Templates)
There are two main types of review markup you will use: Review (for a single review from one person) and AggregateRating (for the average score of many reviews).
Template 1: Single Review Schema
Use this code when you want to highlight one specific, glowing review from a customer for a specific product or service.
`json
{
"@context": "https://schema.org/",
"@type": "Review",
"itemReviewed": {
"@type": "Product",
"name": "Premium Exterior House Painting"
},
"author": {
"@type": "Person",
"name": "John Smith"
},
"reviewRating": {
"@type": "Rating",
"ratingValue": "5",
"bestRating": "5",
"worstRating": "1"
},
"reviewBody": "The team did an incredible job painting the exterior of our home. They were on time and very professional.",
"datePublished": "2025-01-15"
}
`
Line-by-Line Breakdown:
@context and @type: These tell search engines that the following code uses the Schema.org vocabulary and that the object is a Review.
itemReviewed: This defines what is being reviewed. In local services, treat your specific service packages as "Products".
author: You must include the name of the person who left the review.
reviewRating: This tells the search engine the score. Always define bestRating (usually 5) and worstRating (usually 1) so search engines don't misinterpret your scale.
Template 2: Aggregate Rating Schema
This is the code that generates the most powerful rich snippets. It shows the average rating and the total volume of reviews. Use this on specific product pages or service pages where you display multiple reviews.
`json
{
"@context": "https://schema.org/",
"@type": "Product",
"name": "Premium Exterior House Painting",
"description": "Complete exterior painting service for residential homes.",
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "4.8",
"reviewCount": "112",
"bestRating": "5",
"worstRating": "1"
}
}
`
Line-by-Line Breakdown:
- Notice that the main
@type here is Product. You attach the aggregateRating property inside the product you are describing.
ratingValue: The mathematical average of your reviews.
reviewCount: The total number of reviews.
Step-by-Step: Injecting the Code into Your Website
Once you have customized the JSON-LD templates with your actual customer data, you need to put the code on your website. The exact process depends on how your website is built.
For Static HTML Websites
If you hand-code your website, simply copy your JSON-LD block and wrap it in a script tag like this:
<script type="application/ld+json">
[PASTE YOUR JSON CODE HERE]
</script>
Paste this entire block into the <head> section of the specific HTML file for that service. If you cannot access the head section, placing it near the bottom of the <body> will also work, though the head is preferred for faster crawling.
For WordPress Websites
If you use WordPress, do not try to paste script tags directly into the visual text editor; WordPress will strip the code. Instead, use an SEO plugin like RankMath or Yoast, which have built-in schema generators.
Alternatively, you can use a plugin like "WPCode - Insert Headers and Footers". This allows you to paste the raw JSON-LD script into the header of specific pages. For example, if you are following a house painting company Google Business Profile setup guide, you will want your local landing pages to perfectly mirror the services listed in your profile. You would use WPCode to inject the AggregateRating script only on the specific landing page for "Exterior Painting", not globally across the whole site.
For Google Tag Manager
Advanced marketers use Google Tag Manager (GTM) to inject schema. You can create a new "Custom HTML" tag, paste your script block, and set a trigger for the tag to fire only on the specific URL of the service being reviewed. This keeps your actual website code completely clean and allows you to manage all schema markup from a single dashboard.
Testing and Validating Your Structured Data
Never guess if your code works. A single missing comma in a JSON-LD block will break the entire script, and search engines will ignore it entirely. Before you publish your new HTML to your live server, you must test it.
First, use the Google Rich Results Test. You can paste your raw code or input your live URL. This tool will tell you definitively if your page is eligible for review snippets. If there are errors (marked in red), you must fix them. If there are warnings (marked in yellow), it means you are missing optional properties, but the snippet can still function.
Second, run your URL through the Schema.org Validator. While Google's tool tests for rich snippet eligibility, the Schema validator tests for strict adherence to the global Schema vocabulary. Passing both tests ensures your code is bulletproof across all search engines and AI platforms.